Today I am going to share with my readers the ten commonly asked interview questions in java interview. These questions are based on survey that I conducted on my friends who were attending interview of different companies.
This survey was conducted majorly on candidates having 1-4 years of experience in java.

  • Why iterator is fail-fast in java?
Iterator is considered fail-fast as it will fail immediately if it feels that the Collection on which it is iterating currently is about to get modified by self/another thread. Here modification means addition, deletion or updating of element. And this modification may result in non-deterministic behavior at an undetermined time in future. In such cases, iterator fails by throwing  ConcurrentModificationException. Click to learn more with example

  • How is String immutable in java?
String is immutable. A detailed explanation citing the reason behind this immutability is already written in this article

  • Can we call run() directly on thread without calling start()?
  • What is the difference between checked and unchecked exception in java?
  • Reverse the given String in java, eg Rajneesh
  • Difference between StringBuffer and StringBuilder in java?
We know String is immutable in java. So to perform modification on String we use either StringBuffer or StringBuilder. Though they perform same task but still they differ on certain parameters. Lets check out the difference here

  • Class variable vs instance variable
  • Parse the given string to date in java
  • = = vs equal() in java
This is one of the most frequently asked java interview question. You will use either of them while coding number of times.
So lets take a walk through to the difference between the two.

First thing that you should be aware of is that both are used to compare two objects. But this question is generally asked in relation to String because each of them when used to compare String Objects behaves differently. Lets see the detailed explanation here

  • ArrayList vs LinkedList
Array list and Linked list both implements list interface. Now if you have to use one then which one will you prefer. For this we have to think about the number of elements we have to insert or delete from the list, memory consumption, which will help in searching the element faster, etc. Click to read more…

Source link

Ten common java interview question

Leave a Reply

Your email address will not be published. Required fields are marked *