Here are few interview questions in core Java that I usually ask while interviewing...
![]() | ![]() |
6. How do you identify if a duplicate element is being added in a Set?
7. In which case will you may have to write a private inner class and why?
8. If there are 2 classses A and B, while Class A has 2 methods a1() and a2() and Class B has 2 methods b1() and b2(). Consider a case where both b1() and b2() are synchronized. What happens when A.a1() calls B b = new B(); b.b1(); and A.a2() calls B b = new B(); b.b2()?
9. If there are 2 classses A and B, while Class A has 2 methods a1() and a2() and Class B has 2 static methods b1() and b2(). Consider a case where both b1() and b2() are synchronized. What happens when A.a1() calls B.b1(); and A.a2() calls B.b2()?
10. If there are 2 classses A and B, while Class A has 2 methods a1() and a2() and Class B has a static method b1() and a non-static method b2(). Consider a case where both b1() and b2() are synchronized. What happens when A.a1() calls B.b1(); and A.a2() calls B b = new B(); b.b2()?
11. What would you do if you need a synchronized HashSet?
12. What is the use of anonymous class and when do you write it?
13. When does JVM know that its time to kill itself?
14. What are the various algorithms used for GC in Java?
15. How do you avoid your class to be cloned?
16. Do we have memory leaks problem in java? If not, why? If yes how to avoid them or fix them?
Chekout the new Some more Core Java Questions I usually ask for the Entry level people in J2EE field. New
| Email your feedback to Girish |
Disclaimers: No claims are made about the accuracy of any of the document presented in this site and no responsibility is taken for any errors. All the links provided in this site are individual compilation, however no claims are made about the accuracy and authenticity of the respective contents.