Core Java Interview Questions
-
Why is Java platform-independent?
Java compiles to bytecode that a compatible JVM can execute across operating systems.
-
What is JIT compilation?
The JVM can compile frequently executed bytecode into native machine instructions at runtime.
-
Overloading vs overriding?
Overloading selects among different parameter signatures at compile time. Overriding enables runtime dispatch of instance methods.
-
Abstract class vs interface?
Abstract classes support instance state and constructors. Interfaces define contracts and can also include default, static and private methods.
-
Checked vs unchecked exceptions?
Checked exceptions must generally be caught or declared. Unchecked exceptions do not have that requirement.
-
How does synchronization work?
Java monitors coordinate access to shared state and provide memory visibility guarantees.
-
What are the main collection types?
Lists represent sequences, sets enforce uniqueness, and maps associate keys with values.
-
HashMap vs ConcurrentHashMap?
ConcurrentHashMap supports concurrent access; HashMap does not provide thread safety.
-
How does Java pass arguments?
Always by value, including copies of object references.
-
What is serialization?
Conversion of object state into a representation suitable for storage or transmission. Never deserialize untrusted native Java serialized data.
Example
interface Shape {
double area();
}
record Circle(double radius) implements Shape {
public double area() {
return Math.PI * radius * radius;
}
}Reference
Java Core Interview Questions & Answers and 240 Core Java Interview Questions and Answers (uploaded PDFs).