11 cards, each one idea: what it is, a worked example, and the trap to dodge.
The four pillars?
Encapsulation bundles data with methods and hides internals behind access control. Abstraction exposes only what callers need. Inheritance lets a class reuse and extend another. Polymorphism lets one interface work over many types, resolved at runtime via overriding.
One example each beats four definitions: private fields + getters, an abstract Shape, Dog extends Animal, area() behaving per shape.
Trap: Expect: encapsulation vs abstraction? Encapsulation hides DATA; abstraction hides COMPLEXITY.
Class vs object?
A class is the blueprint: fields and methods defined once. An object is a runtime instance of that blueprint with its own state. One class, many objects.
Car is the class; your specific car with plate MH-12 is an object.
Overloading vs overriding?
Overloading: same method name, different parameter lists, in the same class, resolved at compile time. Overriding: a subclass redefines a superclass method with the same signature, resolved at runtime, enabling polymorphism.
add(int, int) and add(double, double) overload; Dog.speak() replacing Animal.speak() overrides.
Trap: Return type alone cannot overload a method; parameters must differ.
Abstract class vs interface?
An abstract class can hold state and partial implementation, and a subclass extends exactly one. An interface is a contract of methods a class promises to implement; a class can implement many. Use an abstract class for shared code among close relatives, interfaces for capabilities across unrelated types.
Bird as an abstract class; Flyable as an interface a Plane can also implement.
Trap: Java probe: interfaces can have default methods since Java 8, so 'no implementation' is outdated; say it before they do.
Inheritance types and the diamond problem?
Single, multilevel, hierarchical, multiple, hybrid. The diamond problem: two parents inherit from one grandparent and a child inherits both, making the inherited member ambiguous. Java avoids it by banning multiple class inheritance (interfaces are fine); C++ resolves it with virtual inheritance.
Trap: Name the language's fix, not just the problem.
Access modifiers?
private: the class only. default (package-private in Java): the package. protected: package plus subclasses. public: everyone. Keep fields private and expose the minimum surface.
Trap: Java probe: protected is MORE open than default, not less; ordering them wrongly is common.
static and final?
static members belong to the class, not instances: one copy, accessible without an object. final on a variable means assign once; on a method, no overriding; on a class, no subclassing.
Math.PI is public static final: shared constant, never reassigned.
Trap: Can a static method be overridden? No, it is hidden, not overridden; dispatch is compile time.
Composition vs inheritance?
Inheritance is an is-a relationship; composition is has-a, where a class holds another and delegates. Composition is more flexible: you can swap parts at runtime and avoid fragile deep hierarchies. Default to composition; inherit only for a true is-a with stable behavior.
Car has-an Engine (composition), not Car extends Engine.
Trap: Expect a design question: 'Penguin extends Bird with fly()' is the standard broken-hierarchy bait.
Java staples: String, == vs equals, HashMap?
String is immutable: every modification creates a new object, which enables the string pool, thread safety and safe map keys. == compares references, equals() compares content. HashMap hashes the key to a bucket; collisions chain in a list that becomes a red-black tree in Java 8+ when long; average O(1) get and put.
new String("a") == "a" is false; .equals is true.
Trap: Follow-up chain: why must you override hashCode when overriding equals? Equal objects must share a bucket.
C++ staples: virtual, pointers vs references?
virtual enables runtime dispatch through the vtable; without it, the static type decides which method runs. A base class needs a virtual destructor if deleted through a base pointer. Pointers can be null and reseated; references must bind at creation and cannot be reseated.
Trap: Deleting a derived object via a base pointer without a virtual destructor is undefined behavior; interviewers love this.
SOLID in one pass?
Single responsibility: one reason to change. Open-closed: open to extension, closed to modification. Liskov substitution: subtypes must work wherever the base does. Interface segregation: many small interfaces beat one fat one. Dependency inversion: depend on abstractions, not concretions.
The Penguin that cannot fly violates Liskov if Bird promises fly().
Trap: Do not just expand the acronym; have a one-line example ready for whichever letter they pick.