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 coding, array, OOP, main method, Collections, ArrayList, Enums, Threads, design patterns, JDBC, SQL, Linux, 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:
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.
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.
- 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 a 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)
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. - What is method overloading in Java? (answer)
- What is method overriding in Java? (answer)
- What is the method hiding in Java?
- What are the 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 the static method in Java? (answer)
- Can we prevent overriding a method without using the final modifier? (answer)
- Can we override a private method in Java? (answer)
- What is the covariant method overriding? (answer)
- Can we change the return type of method to subclass while overriding?
- Can we change the argument list of the overriding method?
- Can we override a method that throws runtime exceptions without the throws clause?
- How do you call the superclass version of an overriding method in sub-class?
- What are the 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 the 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)
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.
- Can we call one constructor from another 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 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.
- How do you override equals(), hashCode() and compareTo() in Java? (answer)
- What is a 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)
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.
- 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 the producer-consumer problem in Java? (solution)
- 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
- 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 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.
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.
ReplyDeleteVery Useful
ReplyDelete