Java Interview Questions Answers for Freshers (1 to 4 years experienced)

I have shared many posts about Java Interview Questions but in this article, I will share Java Interview questions and answers especially for junior Java developers. This includes college graduates, who are looking for the job, Java programmers who have 1 to 2 years of experience in Java and junior developers who have 2 to 4 years of experience in Java, C++ etc. At this level, Java questions are usually not very tough. If you have good knowledge of key programming areas e.g. data structure and algorithms, and a good understanding of Java programming language and JDK API, then you are in good shape. Interviewer often looks for candidates who are willing to learn, good at learning in quick time and knows basic stuff e.g. sorting list, searching through the array, starting stopping a thread and can read existing code. In this article, you will find questions from the areas targeted by Interview for freshers and Java developers with 1 to 4 years of experience e.g. coding, arrayOOP, main methodCollections, ArrayListEnums, Threads, design patterns, JDBC, SQL, Linux and other basic concepts.


Java Interview Questions and Answers for Freshers

Here is the list of some Java questions from interviews mainly from junior developers with 1, 2 or 3 years of experience. It is also good for advanced Java developers with 4 to 5 years of experience to prepare for their telephonic round. I am sure you have seen a lot of these questions already in your Java interviews but having a list is really handy, especially if you are looking for quick revision.


Java Interview Questions from Collections
How to remove duplicates from ArrayList in Java? (answer)
How to reverse ArrayList in Java? (answer)
The difference between an array and ArrayList in Java? (answer)
How to synchronize ArrayList in Java? (answer)
When to use ArrayList and LinkedList in Java? (answer)
The difference between ArrayList and HashSet in Java? (answer)
How to loop over ArrayList in Java? (answer)
The difference between Vector and ArrayList in Java? (answer)
How to create and initialize ArrayList in one line? (answer)
How to sort ArrayList in Java? (answer)
The difference between HashMap and ArrayList in Java? (answer)
How to use ArrayList in Java? (answer)
How to convert ArrayList to String in Java? (answer)
How to get sublist from ArrayList in Java? (answer)
Difference between length() of array and size() of ArrayList in Java? (answer)
What is CopyOnWriteArrayList in Java? (answer)
How to remove objects from ArrayList in Java? (answer)
How to check if a given element exists in ArrayList? (answer)
How to make ArrayList read only in Java? (answer)
How to sort ArrayList in descending order in Java? (answer)
What is the difference between HashSet and TreeSet in Java? (answer)
What is the difference between TreeMap and TreeSet in Java? (answer)
What is the difference between List, Set, and Map in Java? (answer)



Java Interview Questions based on OOP concepts
What is method overloading in Java? (answer)
What is method overriding in Java? (answer)
What is method hiding in Java?
What are rules of method overloading and overriding in Java? (answer)
The difference between method overloading and overriding? (answer)
Can we overload a static method in Java? (answer)
Can we override static method in Java? (answer)
Can we prevent overriding a method without using the final modifier?
Can we override a private method in Java? (answer)
What is covariant method overriding?
Can we change the return type of method to subclass while overriding?
Can we change argument list of overriding method?
Can we override a method which throws runtime exception without throws clause?
How do you call superclass version of an overriding method in sub class?
What are rules of method overloading in Java?
Can we override a non-static method as static in Java? (answer)
Can we override the final method in Java? (answer)
Can we have a non-abstract method inside interface?
What is the default method of Java 8?
What is an abstract class in Java?
What is an interface in Java? What is the real user of an interface? (answer)
The difference between Abstract class and interface? (answer)
Can we make a class abstract without an abstract method?
Can we make a class final and abstract?
Can we overload or override the main method in Java? (answer)
What is the difference between Polymorphism, Overloading, and Overriding? (answer)
Can an interface extend more than one interface in Java?
Can a class extend more than one class in Java?
What is the difference between abstraction and polymorphism in Java? (answer)


Java Interview Questions on Constructor
Can we call one constructor from other in Java? (answer)
Can we declare a constructor in abstract class in Java? (answer)
Can a class have more than one constructor in Java? (answer)
What is the difference between a method and a constructor in Java? (answer)
What is the difference between this() and super() in Java? (answer)
Can we override constructor in Java? (answer)


Basic Java Interview Questions
How do you override equals(), hashCode() and compareTo() in Java? (answer)
What is blank final variable in Java? (answer)
What is the difference between this and super keyword in Java? (answer)
What is the difference between Comparator and Comparable in Java? (answer)


Java Interview Questions from Multithreading
What is the difference between Runnable and Callable in Java? (answer)
Which one is better, implements Runnable or extends Thread? (answer)
wait() and notify() method are defined in which class? (answer)
What is the difference between CountDownLatch and CyclicBarrier? (answer)
How to solve producer consumer problem in Java? (solution)
Can we make a method volatile in Java? (answer)



Java Interview Questions on Serialization
What is default serialization in Java? (answer)
What is the difference between Serializable and Externalizable in Java? (answer)


That's all in this list of Java Interview Questions and answers for Freshers and computer science graduates. These interview questions are also good to prepare for internship jobs, where only basic knowledge and fundamentals are tested. Remember, if you don't know the answer just says so, don't bluff and always listen to interviewer carefully because on freshers interview, most of the interviewer likes to see if the candidate is willing to learn and listen or not.


Couple of books to prepare for Java Interviews
Today, you guys are lucky as there are a couple of good books you can use to prepare for your Java interviews e.g. Programming Interview exposed and Java Programming Interviews exposed, both are the excellent book for freshers and Java developers with 1 to 4 years of experience. For more practice, you can also take help from Cracking the Coding Interview book, which contains another 150+ problems and solutions.





2 comments:

  1. These are good basic Java questions for freshers and junior developers and college graduates and if you are doing Java development for couple of years you can easily answer them without any preparation. Only question which I have not seen before was " Can we make a method volatile?" answer is No, because volatile can only be applied to member variables. You can not even make local variable volatile, why? because they are not shared between multiple threads and compile will throw error.

    ReplyDelete