Saturday, April 6, 2013

Questions that most Java candidates answer wrongly !!


There are few questions for which I rarely find right answer from the interview Candidates, here is the list ..

1. Is it required to synchronize the accessor of a shared mutable object in case of multi-threading ? Why ?

2. In which scenario StringBuilder should be preferred over String class ?

3. I am working on an application where millions of temporary StringBuilder objects are being created, due to which app is facing large GC pauses, how would you rectify the problem, assuming that memory available can not be increased to great extent.

4. How Atomic updates are different from their synchronized counterpart ?

5. When do we get the ConcurrentModificationException ? What constitutes the structural modifications in a collection?

6. Is it possible to write a method in Java which can swap two int variable ? What if we change the type from int to Integer ?

7. What is difference between Class and the Instance level locking ?

8. Can you prove a scenario where thread starvation occurs ?

9. Is it a mandate to make all fields final inside a immutable class ? If yes, why ?

10. How to fix Double Check Locking (DCL multi-threading singleton problem)?

11. What is Java Memory Model ? Who should read it ?

12. What is upper bound and lower bound in generics ?

13. What happens when an exception is thrown from a try block which has no catch clause. But in finally block, a value is returned by the method ? Discuss the scenario.

No comments:

Post a Comment

Your comment will be published after review from moderator