Top 50 Core Java  Interview Questions (2025 Updated)

Top 50 Core Java  Interview Questions (2025 Updated)

What is Java?

Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995.  It follows the WORA (Write Once, Run Anywhere) principle, allowing compiled Java code to run on all platforms that support Java without recompilation

JVM, JRE, and JDK Explained

JDK (Java Development Kit): Tools for developing Java programs, including the compiler and debugger. – JRE (Java Runtime Environment): Provides libraries and JVM to run Java applications. – JVM (Java Virtual Machine): Executes Java bytecode, enabling platform independence.

Core OOP Principles in Java

Encapsulation: Binding data and code together. – Abstraction: Hiding implementation details. – Inheritance: Code reuse through parent-child relationships. – Polymorphism: One name, multiple forms (method overloading/overriding

== vs. .equals()

==: Checks reference equality. .equals(): Checks content equality.

Understanding Constructors

A constructor is a special method used to initialize objects. It has the same name as the class and no return type.

String a = new String("Java"); String b = new String("Java"); System.out.println(a == b);       // false System.out.println(a.equals(b));  // true

Overloading vs. Overriding

Overloading: Same method name with different parameters (compile-time). – Overriding: Subclass provides a specific implementation of a method already defined in its superclass (runtime)

ArrayList vs LinkedList

ArrayList – Uses a dynamic array internally. – Provides fast random access  – Insertion and deletion are slow,because elements may need to be shifted. – Better suited for read-heavy operations. – Resizes dynamically  – Not efficient for frequent insertions/removals in the middle of the list.

LinkedList – Uses a doubly linked list internally. – Access time is slower due to sequential traversal. – Insertion and deletion are faster, especially at the beginning or end  – Consumes more memory  – Better suited for write-heavy operations (frequent adds/removes). – No resizing cost, as elements are linked individually.

Interface vs Abstract Class

– Interface = 100% abstraction – Abstract = partial abstraction Java 8+ lets interfaces have default methods!

Threads in Java

Threads = multitasking. Use Thread or Runnable to run code in parallel. Avoid Thread.sleep() without need!

Access Modifiers Explained

– public: everywhere – private: class only – protected: package + subclass – default: package-level