Java OOP Interview Preparation Guide
1️⃣ Object-Oriented Programming (OOP) Basics
Definition:
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of "objects,"
which can contain data (fields) and code (methods).
Key Principles:
Encapsulation: Data hiding using private variables and public methods.
Abstraction: Hiding implementation details, exposing only necessary functionalities.
Inheritance: Acquiring properties and behavior from a parent class.
Polymorphism: The ability of different objects to respond uniquely to the same method.
2️⃣ Types of Classes in Java
1. Concrete Class (Regular class, can be instantiated)
✅ Example:
class Car {
void drive() {
System.out.println("Car is moving...");
2. Abstract Class (Cannot be instantiated, must be extended)
✅ Example:
abstract class Animal {
abstract void sound();
class Dog extends Animal {
void sound() {
System.out.println("Bark");
3. Final Class (Cannot be inherited)
✅ Example:
final class MathUtils {}
4. Static Nested Class
✅ Example:
class Outer {
static class Inner {
void display() {
System.out.println("Static Inner Class");
5. Inner Class (Non-Static)
✅ Example:
class Outer {
class Inner {
void display() {
System.out.println("Non-Static Inner Class");
6. Anonymous Class
✅ Example:
abstract class Animal {
abstract void sound();
public class Main {
public static void main(String[] args) {
Animal myPet = new Animal() {
void sound() {
System.out.println("Meow");
};
myPet.sound();
7. Singleton Class
✅ Example:
class Singleton {
private static Singleton instance;
private Singleton() {}
public static Singleton getInstance() {
if (instance == null) instance = new Singleton();
return instance;
3️⃣ Types of Objects in Java
1. Mutable Object (Values can change)
✅ Example:
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World");
System.out.println(sb); // Output: Hello World
2. Immutable Object (Values cannot change)
✅ Example:
String str = "Hello";
str = str + " World";
System.out.println(str); // Output: Hello World
3. Deep Copy Object (Creates a separate copy of data)
✅ Example:
class Student implements Cloneable {
String name;
Student(String name) {
this.name = name;
}
protected Object clone() throws CloneNotSupportedException {
return new Student(this.name);
4. Shallow Copy Object (Copies reference, not actual object)
✅ Example:
class Student {
String name;
Student(String name) {
this.name = name;
public class Main {
public static void main(String[] args) {
Student s1 = new Student("Alice");
Student s2 = s1; // Shallow Copy
s2.name = "Bob";
System.out.println(s1.name); // Output: Bob
4️⃣ Types of Inheritance
1. Single Inheritance
✅ Example:
class Animal {
void eat() {
System.out.println("Eating...");
class Dog extends Animal {}
2. Multilevel Inheritance
✅ Example:
class A {
void methodA() { System.out.println("A"); }
class B extends A {
void methodB() { System.out.println("B"); }
class C extends B {
void methodC() { System.out.println("C"); }
3. Hierarchical Inheritance
✅ Example:
class Animal {
void sound() { System.out.println("Animal Sound"); }
class Dog extends Animal {
void bark() { System.out.println("Bark"); }
class Cat extends Animal {
void meow() { System.out.println("Meow"); }
5️⃣ Types of Polymorphism
1. Compile-Time (Method Overloading)
✅ Example:
class MathUtils {
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }
2. Run-Time (Method Overriding)
✅ Example:
class Parent {
void show() { System.out.println("Parent"); }
class Child extends Parent {
void show() { System.out.println("Child"); }
6️⃣ Important Concepts for Interviews
SOLID Principles
Memory Management & Garbage Collection
Java 8 Features (Lambdas, Streams, Functional Interfaces)
Threading & Multithreading
Difference Between ArrayList & LinkedList
Exception Handling (Checked vs Unchecked Exceptions)
🕒 Preparation Time:
Beginner: 4-6 Days
Intermediate: 2-3 Days
Revision: 1-2 Days
🎯 Final Action Plan
✅ Revise All OOP Topics ✅ Solve 20+ Java OOP Interview Questions ✅ Code and Test Real Examples
✅ Do 1-2 Mock Interviews
🚀 Best of Luck for Your Java Interview!