🧠 Java OOP & Exception Handling Flash Cards
Use these flash cards for fast recall before your exam. Each concept is on a separate card.
🔹 Inheritance
One class gets features from another.
✅ Syntax: class B extends A
🔹 super keyword
Calls parent constructor or method.
✅ Syntax: super(); or super.var
🔹 Constructor Execution
Parent constructor runs first.
✅ Order: Super → Sub
🔹 Types of Inheritance
Single: A → B
Multilevel: A → B → C
Hierarchical: A → B, A → C
🔹 Method Overriding
Same method name in child class.
✅ Runtime replacement of base method
🔹 Polymorphism
Same method behaves differently based on object type.
✅ A obj = new B(); obj.show();
🔹 Dynamic Method Dispatch
Method call decided at runtime.
✅ Based on actual object, not reference type.
🔹 Abstract Class
Has incomplete methods.
✅ Cannot be instantiated.
✅ Subclass must override abstract methods.
🔹 final Keyword
Locks class, method, or variable.
✅ final class → can't extend
✅ final method → can't override
🔹 Object Class
Base of all Java classes.
✅ Common methods: toString(), equals(), getClass()
🔹 Interface
All methods abstract by default.
✅ A class must implement all methods.
🔹 Default Method in Interface
Has a body in interface.
✅ Optional to override in class.
✅ Introduced in Java 8
🔹 Static Method in Interface
Belongs to interface.
✅ Called using InterfaceName.method()
✅ Not inherited
🔹 Private Method in Interface
Helper inside interface.
✅ Only used by default/static methods
✅ Introduced in Java 9
🔹 Packages
Folders to organize classes.
✅ Syntax: package mypack;
🔹 Importing Classes
Brings classes into your file.
✅ import java.util.Scanner;
🔹 Access Modifiers
public – everywhere
default – same package
protected – package + subclass
private – same class
🔹 Custom Exception
User-defined exception class.
✅ class MyException extends Exception
🔹 Chained Exception
One exception causes another.
✅ e1.initCause(e2);
✅ Track root cause