Core Java Interview Preparation Guide
(3 Years Experience)
1. Data Types & Variables
Data types define the type of data a variable can hold. Java has primitive and non-primitive
types.
Primitive: int, float, double, char, boolean
Example:
int a = 10;
Why: Helps JVM allocate memory efficiently.
Interview Q: What is the difference between int and Integer?
Answer: int is primitive, Integer is wrapper class.
2. Arrays
Array is a collection of similar elements stored in contiguous memory.
Example:
int[] arr = {1,2,3};
Execution: arr[0]=1, arr[1]=2
Interview Q: Difference between array and ArrayList?
Answer: Array is fixed size, ArrayList is dynamic.
3. Strings
String is immutable in Java.
Example:
String s = "hello";
Why immutable: Security, performance.
Interview Q: String vs StringBuilder?
Answer: String is immutable, StringBuilder is mutable.
4. OOP Concepts
Encapsulation: Binding data and methods
Inheritance: Acquiring properties
Polymorphism: Many forms
Abstraction: Hiding details
Interview Q: What is polymorphism?
Answer: Method overloading and overriding.
5. Exception Handling
Used to handle runtime errors.
Example:
try { int a = 10/0; } catch(Exception e) {}
Interview Q: Checked vs Unchecked?
Answer: Checked at compile time vs runtime.
6. Collections
List, Set, Map
ArrayList vs LinkedList
HashMap internal working uses hashing.
Interview Q: HashMap internal working?
Answer: Uses hashcode and bucket.
7. Multithreading
Allows concurrent execution.
Example:
Thread t = new Thread();
Interview Q: Difference between process and thread?
Answer: Process is independent, thread is lightweight.