Top 50 Core Java Interview Questions

Core Java questions form the base of almost every Java interview. Here are frequently asked questions covering the fundamentals.

1. What are the main features of Java?

Platform independence, object-oriented design, automatic memory management, multithreading support, and strong security are among Java's key features.

2. What is the difference between JDK, JRE, and JVM?

JVM executes Java bytecode, JRE provides the JVM plus libraries needed to run applications, and JDK includes the JRE plus development tools like the compiler.

3. What is the difference between primitive and non-primitive data types?

Primitive types (int, char, boolean, etc.) store actual values directly, while non-primitive types (objects, arrays, strings) store references to memory locations.

4. What is the difference between == and equals()?

== compares references for objects, while equals() compares the actual content, assuming it's properly overridden.

5. What is the difference between method overloading and overriding?

Overloading is having multiple methods with the same name but different parameters in the same class; overriding is a subclass redefining a superclass method.

6. What is the purpose of the final keyword?

final can be applied to variables (making them constants), methods (preventing overriding), and classes (preventing inheritance).

7. What is the difference between an abstract class and an interface?

Abstract classes can hold state and support single inheritance; interfaces primarily define contracts and support multiple inheritance.

8. What is exception handling, and why is it needed?

Exception handling manages runtime errors gracefully using try, catch, throw, and finally, preventing abrupt program termination.

9. What is garbage collection in Java?

An automatic process where the JVM reclaims memory occupied by objects that are no longer reachable, removing the need for manual memory deallocation.

10. What is the difference between a constructor and a method?

A constructor initializes an object and has no return type, sharing the class name; a method performs an action and has a return type (or void).

Core Java interviews often blend theory questions with a quick whiteboard coding round — make sure you can explain concepts and also implement small examples on the spot.

Master Java with Uncodemy

Hands-on training, live projects, and placement support in our Java Programming Course.

Explore the Course