Frquently asked java interview questions for experienced professionals

If you have attended some Java interviews then you might have an idea about some repeating and common questions like hashtable, hashmap, array list, difference between hash code and equals and many more related questions. These common questions are called frequently asked questions, and every Java professional should be prepared for it. Some Java programmers might already have a list of these questions for their revision, but if you are an experienced developer and looking for such questions, then this guide may be very useful for you.

Here we are going to discuss some questions of advanced Java that you really can’t afford to miss at experienced level.

frequently asked interview questions for experienced professionals

1. What is the basic difference between StringBuffer and StringBuilder?

Well, string builder and string buffer both are mutable and have the same methods. The only difference is that in synchronization. StringBuilder is not synchronized while StringBuffer is synchronized. StringBuffer is thread safe and you can implement threads for your methods but this is not possible in case of StringBuilder.

2. What is the main Difference between implements Runnable and extends Thread used in Java?

Extend Thread class means you cannot extend another class, while in Runnable you can extend another class.

3. Tell me the Difference between Callable and Runnable interface in Java?

Callable also defines a single call () method just like runnable interface but it can throw exceptions and return values.

4. Which method is more efficient in removing and adding element from middle- Array List or Linked List?

It is quite easy and efficient in LinkedList as compared to ArrayList. Linked list only requires modifying links without rearranging any element.

5. What is the use of Wait and Notify Methods in Java?

Main use of both methods is interthread communication.
Wait method – pause the thread on a condition
Notify method- send notification to waiting threads

6. Can you write a Java program to print Fibonacci series?

This is a number series in which a number (n) is equal to the sum of two previous numbers f (n-1) and f (n-2). This is generally used to teach recursion to learners.

7. Can you please tell us how to swap 2 numbers without using temp variable?

XOR trick can be the best solution.

8. What is the main difference between FileReader and FileInputStream in Java?

FileInputStream is mainly used to read binary data.
FileReader is mainly used to read text data, it can be considered useful for character encoding (it converts bytes into text).

9. Is it possible to convert bytes into characters? If yes, then how will you convert it in java?

Yes, bytes can be converted into text data or characters by using character encoding process. You need to provide character encoding to each binary data to convert them into equivalent characters.

10. Is overriding of static method possible in Java?

No, this is not possible in Java because it is solved at compile time. So you have to define and declare these static methods of same signature and name in child class. It hides it from parent class and this is the only reason we call it method hiding.

Leave a comment

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