OOP Cheatsheet by Love Babbar
Links and resources for strengthening the concepts of Object Oriented Programming [Java and C++]
To the point for Interview Preparation and sufficient for Academics.
Love Babbar CheatSheet : cheatsheet
Love Babbar Video : video
Useful Links
| SNo |
Topic |
Link |
Language |
| 1 |
Virtual Functions |
view |
C++ |
| 2 |
Polymorphism |
view |
C++ |
Resources
| SNo |
Language |
Link |
| 1 |
C++ |
view |
| 2 |
Java |
view |
Overview
| SNo |
Topic |
Link |
Date Completed |
| 1 |
What is OOP ? |
view |
not done |
| 2 |
How OOP is related to real world ? |
view |
not done |
| 3 |
Why to study OOPs ? |
view |
not done |
| 4 |
Limitations of OOPs |
view |
not done |
| 5 |
When we say that "X" language is object oriented programming language, then what does we mean by that ? |
homework |
not done |
Classes
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Difference between Structure and Class |
view |
not done |
| 2 |
Similarities between Structure and Class |
view |
not done |
| 3 |
When to use Structure over Class |
homework |
not done |
| 4 |
Access Modifiers |
view |
not done |
| 5 |
Member Function |
view |
not done |
| 6 |
Constructor |
view |
not done |
| 7 |
Destructor |
view |
not done |
Access Specifiers
There are 4 access modifiers in C++ :
- public
- private
- protected
- friend
- protected friend
Member functions
- Inside Class Function --> inline keyword
- Outside Class Function --> scope resolution operator (::)
Constructor
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Default Constructor |
- |
not done |
| 2 |
Parameterised Constructor |
- |
not done |
| 3 |
Copy Constructor : Deep vs shallow copy |
view |
not done |
| 4 |
Copy Constructor : copy ctor vs assignment |
view |
not done |
| 5 |
Virtual Constructor |
view |
not done |
| 6 |
Virtual Copy Constructor |
view |
not done |
| 7 |
Constructor vs member functions |
view |
not done |
| 8 |
Constructor Overloading |
view |
not done |
Destructor
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Private Destructor |
view |
not done |
| 2 |
Virtual Destructor |
view |
not done |
| 3 |
Pure Virtual Destructor |
view |
not done |
| 4 |
Destructor vs member functions |
view |
not done |
| 5 |
Multiple Destructors in one class ? |
view |
not done |
| 6 |
When to write user defined Destructor ? |
view |
not done |
| 7 |
Can a Destructor be virtual ? |
view |
not done |
Objects
| SNo |
Topic |
Link |
Date Completed |
| 1 |
difference btw Class and Object |
view |
not done |
| 2 |
Real world Analogy btw Class and Object |
view |
not done |
Important Keywords
| SNo |
Topic |
Link |
Date Completed |
| 1 |
static |
view |
not done |
| 2 |
virtual |
view |
not done |
| 3 |
abstract |
view |
not done |
| 4 |
final |
view |
not done |
| 5 |
explicit |
view |
not done |
| 6 |
this |
view |
not done |
| 7 |
new |
view |
not done |
| 8 |
const |
view |
not done |
| 9 |
super |
view |
not done |
Features of OOPs :
- Polymorphism
- Inheritance
- Encapsulation
- Abstraction
Polymorphism
| SNo |
Topic |
Link |
Date Completed |
| 1 |
What is Polymorphism ? |
view |
not done |
| 2 |
Need of Polymorphism ? |
view |
not done |
| 3 |
Function / Operator Overloading |
view |
not done |
| 4 |
Function Overriding |
view |
not done |
| 5 |
Virtual Function |
view |
not done |
| 6 |
Virtual Class |
view |
not done |
| 7 |
Derived Class |
view |
not done |
| 8 |
Can Virtual Function be private ? |
view |
not done |
| 9 |
Inline Virtual Function |
view |
not done |
| 10 |
Abstract Class |
view |
not done |
| 11 |
Pure Virtual Function |
view |
not done |
| 12 |
Pure Virtual Destructor |
view |
not done |
Polymorphism is categorised into 2 types :
- Function / Operator Overloading
- Function Overriding
Function / Operator Overloading
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Compile time Polymorphism |
view |
not done |
| 2 |
Functions cannot be overloaded in C++ |
view |
not done |
| 3 |
Operators that cannot be overloaded in C++ |
view |
not done |
Note : Function Overriding is also called run-time Polymorphism.
5 Types of Inheritance
- Single
- Mutliple
- Hierarchical
- Multilevel
- Hybrid / Virtual
Inheritance
| SNo |
Topic |
Link |
Date Completed |
| 1 |
What is Inheritance ? |
view |
not done |
| 2 |
Need of Inheritance |
view |
not done |
| 3 |
Can OOP exist without Inheritance ? |
view |
not done |
| 4 |
Types of Inheritance |
view |
not done |
| 5 |
Real life examples of Multiple Inheritance |
view |
not done |
| 6 |
Limitations of Inheritance |
view |
not done |
| 7 |
Sealed Modifier |
view |
not done |
| 8 |
Calling base method without creating instance |
view |
not done |
| 9 |
new vs override |
view |
not done |
| 10 |
Why JAVA doesn't support Multiple Inheritance |
view |
not done |
| 11 |
Dreaded diamond in Multiple Inheritance |
view |
not done |
| 12 |
Object Slicing |
view |
not done |
| 13 |
Hide base class methods in JAVA |
view |
not done |
| 14 |
Does overloading work with Inheritance |
view |
not done |
| 15 |
Polymorphism vs Inheritance |
view |
not done |
| 16 |
Generalization vs Aggregation vs Composition |
view |
not done |
| 17 |
Friend Function / Class |
homework |
not done |
| 18 |
Local Class, nested Class |
homework |
not done |
| 19 |
Simulating Final Class |
homework |
not done |
Note: If class A inherits from class B, then what all are inherited from parent class and size calculation. Explore all possible combinations
Encapsulation
| SNo |
Topic |
Link |
Date Completed |
| 1 |
What is Encapsulation ? |
view |
not done |
| 2 |
Advantages of Encapsulation |
view |
not done |
| 3 |
How to achieve Encapsulation |
view |
not done |
| 4 |
Code / Implementation of Encapsulation |
view |
not done |
| 5 |
Real world example of Encapsulation |
view |
not done |
Encapsulation is the combination of Data hiding and Abstraction
Abstraction
| SNo |
Topic |
Link |
Date Completed |
| 1 |
What is Abstraction ? |
view |
not done |
| 2 |
When to Abstraction ? |
homework |
not done |
| 3 |
How to achieve Abstraction ? |
view |
not done |
| 4 |
Encapsulation vs Abstraction |
view |
not done |
| 5 |
Interface vs Abstract classes in JAVA |
view |
not done |
Data abstraction is a way of hiding the implementation details and showing only the functionality to the users.
How to achieve :
1) C++ --> Access specifiers and header files
2) JAVA --> Interfaces and Abstract classes
Design Interview Questions
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Design a hashmap |
view |
not done |
| 2 |
Design a LRU cache |
view |
not done |
| 3 |
Design a Call Center |
view |
not done |
| 4 |
Design a deck of cards |
view |
not done |
| 5 |
Design a parking lot |
view |
not done |
| 6 |
Design an online chat |
view |
not done |
Miscellaneous
| SNo |
Topic |
Link |
Date Completed |
| 1 |
Static and Dynamic Binding |
view |
not done |
| 2 |
Message Passing |
view |
not done |
| 3 |
C vs C++ vs JAVA |
view |
not done |
| 4 |
Procedural vs OOPs |
view |
not done |
| 5 |
Why JAVA is not purely OOB |
view |
not done |
| 6 |
Is array primitive or object in JAVA |
view |
not done |
| 7 |
Early and late binding |
view |
not done |
| 8 |
Default access modifier in class |
view |
not done |
| 9 |
No. of instances for an abstract class |
view |
not done |
| 10 |
Garbage Collection |
view |
not done |
| 11 |
Manipulators |
view |
not done |
| 12 |
Finally block |
view |
not done |
| 13 |
Final Variable |
view |
not done |
| 14 |
Exception |
view |
not done |
| 15 |
Error vs Exception |
view |
not done |
| 16 |
Exception Handling |
view |
not done |
| 17 |
Finalize method in JAVA |
view |
not done |
| 18 |
Tokens |
view |
not done |
| 19 |
Ternary Operator |
view |
not done |
| 20 |
Enum |
view |
not done |
| 21 |
Design Patterns |
view |
not done |
| 22 |
Using struct vs class |
view |
not done |
| 23 |
Cohesion vs Coupling |
view |
not done |
Is it possible for a class to inherit the constructor of its base class ?
super keyword
order of constructor and destructor calling sequence in case of various inheritance schemes.
Singleton pattern example.