🔥 Java OOP Crash Guide – Exam Survival Sheet
Use this for last-minute revision. Simple, fast, and clean.
🔹 Inheritance
💡 What: One class gets features from another class.
📦 Code Example:
class Animal { void eat() { } } class Dog extends Animal { }
🧠 Remember: Dog gets eat() from Animal
🔹 super keyword
💡 What: Used to call parent class constructor or variable.
📦 Code Example:
super.i = 10;
🧠 Remember: super = parent access
🔹 Constructor Execution
💡 What: Parent constructor runs before child.
📦 Code Example:
class A { A() { } } class B extends A { B() { } }
🧠 Remember: Parent builds first
🔹 Types of Inheritance
💡 What: Single, Multilevel, Hierarchical.
📦 Code Example:
class A {}
class B extends A {}
class C extends B {}
🧠 Remember: Multilevel = A → B → C
🔹 Method Overriding
💡 What: Child changes parent method behavior.
📦 Code Example:
class A { void show() {} } class B extends A { void show() {} }
🧠 Remember: Same method, new rules
🔹 Polymorphism
💡 What: Same call behaves differently for different objects.
📦 Code Example:
A obj = new B(); obj.show();
🧠 Remember: One call, many results
🔹 Dynamic Dispatch
💡 What: Decides at runtime which method to run.
📦 Code Example:
A obj = new B(); obj.show();
🧠 Remember: Runtime method decision
🔹 Abstract Class
💡 What: Cannot be instantiated. Contains abstract methods.
📦 Code Example:
abstract class A { abstract void run(); }
🧠 Remember: Half-done class
🔹 final Keyword
💡 What: Prevents override or inheritance.
📦 Code Example:
final class A {} final void show() {}
🧠 Remember: Freeze this – no change
🔹 Object Class
💡 What: Top class of all Java classes.
📦 Code Example:
obj.toString();
🧠 Remember: Base of all classes
🔹 Interface
💡 What: List of methods to implement. No bodies.
📦 Code Example:
interface A { void show(); }
🧠 Remember: Must-do list
🔹 Default Interface Method
💡 What: Optional method with body (Java 8+).
📦 Code Example:
default void greet() { }
🧠 Remember: Optional ready method
🔹 Static Interface Method
💡 What: Called with InterfaceName.method().
📦 Code Example:
static void help() { }
🧠 Remember: InterfaceName.method()
🔹 Private Interface Method
💡 What: Helper method for reuse (Java 9+).
📦 Code Example:
private void helper() { }
🧠 Remember: Only for use inside interface