Skip to content
C

Core Java Interview Questions

JVM runs bytecode, JRE is the JVM plus libraries needed to run programs, and JDK is the JRE plus development tools like the compiler. In short: JDK is for developers; JRE is for running Java programs; JVM is the actual execution engine.


Q1. What is the difference between JDK, JRE, and JVM? JVM runs bytecode, JRE is the JVM plus libraries needed to run programs, and JDK is the JRE plus development tools like the compiler. In short: JDK is for developers; JRE is for running Java programs; JVM is the actual execution engine.

Q2. Why is Java called platform-independent? Because Java code compiles into bytecode, which can run on any device that has a JVM installed, without needing to recompile the code separately for each operating system.

Q3. What is the difference between `==` and `.equals()`? == checks whether two references point to the exact same object in memory. .equals() checks whether the actual content of two objects is the same, which is usually what you want when comparing values like Strings.

Q4. What is the difference between method overloading and method overriding? Overloading means multiple methods with the same name but different parameters in the same class, resolved at compile-time. Overriding means a subclass provides its own version of a method already defined in its parent class, resolved at runtime.

Q5. Why are Strings immutable in Java? Immutability makes String objects safe to share across multiple parts of a program (including the String Pool) without risk of one part accidentally changing a value another part depends on. It also supports thread safety and enables the memory-saving String Pool mechanism.

Q6. What is the difference between `ArrayList` and `LinkedList`? ArrayList offers faster access by index but slower insertions/deletions in the middle. LinkedList offers faster insertions/deletions but slower index-based access, since it must traverse node by node.

Q7. What is the purpose of the `final` keyword? final prevents changes: a final variable can't be reassigned, a final method can't be overridden, and a final class can't be extended.

Q8. What is autoboxing and unboxing? Autoboxing is the automatic conversion of a primitive type into its corresponding wrapper class object (e.g., int to Integer). Unboxing is the reverse conversion, back from wrapper to primitive.

Key Points to Remember

  • These core questions are almost always asked in the first round of any Java interview.
  • Practice explaining these answers out loud, in your own words, not just reading them silently.
  • Interviewers often ask a quick follow-up code example after a conceptual answer, so be ready to write a short snippet too.