OOP Notes for Placements and Interviews
Object-oriented programming notes for placement interviews: classes, encapsulation, inheritance, polymorphism, abstraction, SOLID and design patterns, with code.
- Notes: 11
- Reading time: about 3 hours
- Cost: Free, no sign-in needed
Classes and objects, encapsulation, inheritance, polymorphism, abstraction, SOLID and the design patterns interviews ask for.
Read in this order
- Introduction to Object-Oriented Programming — What object-oriented programming is: classes and objects, the four pillars of OOP, procedural vs OOP, and how C++, Java and Python each do it.
- Classes and Objects — Classes and objects in OOP: fields and methods, default, parameterised and copy constructors, destructors vs garbage collection, this, static members.
- Encapsulation — Encapsulation in OOP: data hiding, access modifiers compared across C++, Java and Python, getters and setters with validation, and immutable classes.
- Inheritance — Inheritance in OOP: the is-a relationship, single, multilevel, hierarchical, multiple and hybrid types, overriding, super, constructor order, diamonds.
- Polymorphism — Polymorphism in OOP: compile-time overloading vs run-time overriding, dynamic dispatch and the vtable, upcasting, downcasting and object slicing.
- Abstraction: Abstract Classes and Interfaces — Abstraction in OOP: abstract classes, C++ pure virtual functions, Java interfaces with default and static methods, Python ABCs, and when to use which.
- Association, Aggregation and Composition — Association, aggregation and composition in OOP: has-a vs is-a, object lifetimes, UML notation, ownership in C++, and composition over inheritance.
- SOLID Principles — The five SOLID principles of OOP design — single responsibility, open/closed, Liskov, interface segregation, dependency inversion — with violations and fixes.
- Design Patterns for Interviews — OOP design patterns for interviews: creational, structural and behavioural, with Singleton, Factory, Builder, Adapter, Decorator, Observer and Strategy.
- Object Equality, Hashing and Copying — Object identity vs equality in OOP: == vs equals in Java, == vs is in Python, operator== in C++, the equals/hashCode contract, and shallow vs deep copy.
- Exception Handling in OOP — Exception handling in OOP: try, catch and finally, checked vs unchecked exceptions in Java, custom exception classes, RAII and try-with-resources, with code.
Test yourself
- OOP · Basic proctored skill test with a verifiable credential
- OOP · Intermediate proctored skill test with a verifiable credential