Top 80 Core Java Interview Questions with Answers

Hey Java programmers, if you are preparing for a Core Java interview and looking for some frequently asked Java interview questions for quick revision then you have come to the right place. Earlier, I have shared the best books and best courses for Java interviews.  I have also shared many posts about Java Interview Questions and in this article, I will share Java Interview questions and answers especially for junior Java programmers, someone with 1 to 3 years of experience. 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 3 years of experience in Java, C++, etc. 

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 like codingarrayOOPmain methodCollectionsArrayListEnumsThreadsdesign patternsJDBCSQLLinux, and other basic concepts

At this level (1 to 3 years experienced Java programmers), Java questions are usually not very tough. If you have good knowledge of key programming areas like data structure and algorithms, and a good understanding of Java programming language and JDK API, then you are in good shape. 

The interviewer often looks for candidates who are willing to learn, good at learning in quick time, and knows basic stuff like sorting a list, searching through the array, starting stopping a thread, and can read existing code. 

This list should provide you enough questions to revise key core Java concepts for interviews but if you still need more resources I also recommend Java Interview Guide: 200+ Interview Questions and Answers course on Udemy. Tough there is no substitute for the experience you can still manage to sail through by carefully preparing for your Java interviews.





80+ Core Java Interview Questions for 1 to 3 Years Experienced

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 intermediate 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.  If you need more resources for more in-depth preparation then I recommend Ace the Java Coding Interview track from Educative, which has 8 modules to cover all important topics for Java coding interviews. 




1. Java Interview Questions from Collections Framework

Let's start with the most important topic of Java interviews, The Java collection framework.  This is a seriously very important topic as you won't find a real-world Java application that doesn't use the Java Collection framework. 

This package provides standard Java implementation of common data structures like list, set, map, hash table, queue, stack, etc. Good knowledge of this package is imperative to crack core Java interviews. 

Here is the list of top questions from the Java Collection package:
  1. How to remove duplicates from ArrayList in Java? (answer)
  2. How to reverse ArrayList in Java? (answer)
  3. The difference between an array and ArrayList in Java? (answer)
  4. How to synchronize ArrayList in Java? (answer)
  5. When to use ArrayList and LinkedList in Java? (answer)
  6. The difference between ArrayList and HashSet in Java? (answer)
  7. How to loop over ArrayList in Java? (answer)
  8. The difference between Vector and ArrayList in Java? (answer)
  9. How to create and initialize ArrayList in one line? (answer)
  10. How to sort ArrayList in Java? (answer)
  11. The difference between HashMap and ArrayList in Java? (answer)
  12. How to use ArrayList in Java? (answer)
  13. How to convert ArrayList to String in Java? (answer)
  14. How to get a sublist from ArrayList in Java? (answer)
  15. Difference between length() of array and size() of ArrayList in Java? (answer)
  16. What is CopyOnWriteArrayList in Java? (answer)
  17. How to remove objects from ArrayList in Java? (answer)
  18. How to check if a given element exists in ArrayList? (answer)
  19. How to make ArrayList read-only in Java? (answer)
  20. How to sort ArrayList in descending order in Java? (answer)
  21. What is the difference between HashSet and TreeSet in Java? (answer)
  22. What is the difference between TreeMap and TreeSet in Java? (answer)
  23. What is the difference between List, Set, and Map in Java? (answer)




2. Java Interview Questions based on OOP concepts

This is another topic that is quite common in Java interviews. In this topic, you will find questions from basic OOP concepts like abstraction, encapsulation, inheritance as well as overloading, overriding, static methods, composition, interface, etc. 
  1. What is method overloading in Java? (answer)
  2. What is method overriding in Java? (answer)
  3. What is the method hiding in Java?
  4. What are the rules of method overloading and overriding in Java? (answer)
  5. The difference between method overloading and overriding? (answer)
  6. Can we overload a static method in Java? (answer)
  7. Can we override the static method in Java? (answer)
  8. Can we prevent overriding a method without using the final modifier? (answer)
  9. Can we override a private method in Java? (answer)
  10. What is the covariant method overriding? (answer)
  11. Can we change the return type of method to subclass while overriding?
  12. Can we change the argument list of the overriding method?
  13. Can we override a method that throws runtime exceptions without the throws clause?
  14. How do you call the superclass version of an overriding method in sub-class?
  15. What are the rules of method overloading in Java?
  16. Can we override a non-static method as static in Java? (answer)
  17. Can we override the final method in Java? (answer)
  18. Can we have a non-abstract method inside the interface?
  19. What is the default method of Java 8?
  20. What is an abstract class in Java?
  21. What is an interface in Java? What is the real user of an interface? (answer)
  22. The difference between Abstract class and interface? (answer)
  23. Can we make a class abstract without an abstract method?
  24. Can we make a class final and abstract?
  25. Can we overload or override the main method in Java? (answer)
  26. What is the difference between Polymorphism, Overloading, and Overriding? (answer)
  27. Can an interface extend more than one interface in Java?
  28. Can a class extend more than one class in Java?
  29. What is the difference between abstraction and polymorphism in Java? (answer)

3. Java Interview Questions on Constructor

In this topic, you will find questions from object creation and constructor in Java. This is another concept which is particularly important for junior developer because object creation can be tricky in Java with complex object graph and knowing how constructor calls each other really helps. 
  1. Can we call one constructor from another in Java? (answer)
  2. Can we declare a constructor in abstract class in Java? (answer)
  3. Can a class have more than one constructor in Java? (answer)
  4. What is the difference between a method and a constructor in Java? (answer)
  5. What is the difference between this() and super() in Java? (answer)
  6. Can we override the constructor in Java? (answer)

4. Basic Java Interview Questions

In this topic, you will find questions Java questions from basic Java concepts like equals and hashcode, final variables, this and super keyword as well how to compare object using Comparable and Comparator in Java. 
  1. How do you override equals(), hashCode() and compareTo() in Java? (answer)
  2. What is a blank final variable in Java? (answer)
  3. What is the difference between this and super keyword in Java? (answer)
  4. What is the difference between Comparator and Comparable in Java? (answer)

5. Java Interview Questions from Multithreading

This is another important topic that is quite common in core Java interviews. In this topic, you will find questions from basic multithreading concepts like threads, locking, deadlock as well concurrency patterns like producer-consumer, wait, notify, and modern concurrency utilities like CountdownLatch and Cyclicbarrier in Java. 
  1. What is the difference between Runnable and Callable in Java? (answer)
  2. Which one is better, implements Runnable, or extends Thread? (answer)
  3. wait() and notify() method are defined in which class? (answer)
  4. What is the difference between CountDownLatch and CyclicBarrier? (answer)
  5. How to solve the producer-consumer problem in Java? (solution)
  6. Can we make a method volatile in Java? (answer)

6. Java Interview Questions on Serialization

This is another tricky topic for core Java interviews. In this topic, you will find questions from key serialization concepts like how to save and retrieve Java objects, how the serialization process works, and how to customize the serialization process in Java
  1. What is default serialization in Java? (answer)
  2. 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 say so, don't bluff, and always listen to the interviewer carefully because, on freshers interview, most of the interviewer likes to see if the candidate is willing to learn and listen or not.



Other Interview Questions Articles you may like to explore
  • Top 10 Spring Framework Interview Questions with Answers (see here)
  • 50+ Data Structure and Algorithms Problems from Interviews (questions)
  • 10 Hibernate Interview Questions for Java EE developers (see here)
  • 10 XML Interview Questions for Java Programmers (read here)
  • 20 Java Design Pattern Questions asked on Interviews (see here)
  • 10 Servlet Interview Questions with Answers (see here)
  • 10 Oracle Interview Questions for Java developers (see here)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • 12 RESTful Web Services Questions from Interviews (read here)
  • Top 10 JMS and MQ Series Interview Questions and Answers (list)
  • Review these 50 Java questions before interviews (review)
  • 10 JDBC Interview Questions for Java Programmers (questions)
  • 15 Java NIO and Networking Interview Questions with Answers (see here)
  • 15 Data Structure and Algorithm Questions from Java Interviews (read here)
  • Top 10 Trick Java Interview Questions and Answers (see here)
  • Top 40 Core Java Phone Interview Questions with Answers (list)

Thanks for reading this article so far. If you like these Core Java Interview questions for 1 to 4 years of experienced professionals then please share them with your friends and colleagues. If you have any questions or feedback then please drop a note.


P.S.  - Today, you guys are lucky as there are a couple of good books you can use to prepare for your Java interviews like my book Grokking the Java Interview and Java Programming Interviews exposed by Apress, both are excellent books for freshers and Java developers with 1 to 4 years of experience. 

P.S. - For coding problems, you can also take help from Cracking the Coding Interview 6th edition book, which contains another 189+ 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

Feel free to comment, ask questions if you have any doubt.