TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview ยท 52.2K subscribers
Post #2737 2.06K
โœ… OOP Interview Questions with Answers Part-4 ๐Ÿง ๐Ÿ’ป

31. What is SOLID in OOP?
SOLID is a set of 5 design principles for writing maintainable, scalable OOP code. It stands for:
S โ€“ Single Responsibility
O โ€“ Open/Closed
L โ€“ Liskov Substitution
I โ€“ Interface Segregation
D โ€“ Dependency Inversion

32. Explain each SOLID principle briefly:
โ€ข Single Responsibility โ€“ A class should do one thing only.
โ€ข Open/Closed โ€“ Classes should be open for extension, but closed for modification.
โ€ข Liskov Substitution โ€“ Subclasses should replace their parent classes without breaking functionality.
โ€ข Interface Segregation โ€“ Prefer small, specific interfaces over large ones.
โ€ข Dependency Inversion โ€“ Depend on abstractions, not concrete classes.

33. What is Liskov Substitution Principle?
If a class S is a subclass of class T, objects of type T should be replaceable with objects of type S without affecting the program.
Example: A Bird base class with a fly() method may break if Penguin inherits it (Penguins can't fly). So, design must respect capabilities.

34. What is Dependency Inversion Principle?
High-level modules should not depend on low-level modules. Both should depend on abstractions.
Example: A service class should depend on an interface, not a specific implementation.

35. What is object slicing?
Occurs when an object of a derived class is assigned to a base class variable โ€” the extra properties of the derived class are "sliced off."
Example: C++ object slicing when passing by value.

36. What are getters and setters?
Special methods used to get and set values of private variables in a class.
They support encapsulation and validation.
def get_name(self): return self._name  
def set_name(self, name): self._name = name


37. What is a virtual function?
A function declared in the base class and overridden in the derived class, using the virtual keyword (in C++). Enables run-time polymorphism.

38. What is early binding vs late binding?
โ€ข Early Binding (Static): Method call is resolved at compile time (e.g., method overloading).
โ€ข Late Binding (Dynamic): Method call is resolved at run-time (e.g., method overriding).

39. What is dynamic dispatch?
Itโ€™s the process where the method to be invoked is determined at runtime based on the objectโ€™s actual type โ€” used in method overriding (late binding).

40. What is a pure virtual function?
A virtual function with no implementation in the base class โ€” makes the class abstract.
Syntax (C++):
virtual void draw() = 0;


๐Ÿ’ฌ Double Tap โ™ฅ๏ธ for Part-5
  • โค 7
More from @crackingthecodinginterview
  1. Oct 9, 2026๐Ÿ”ฅ SQL Interview Case Studies (Advanced Business Scenarios) ๐Ÿ’ฏ ๐Ÿง  Case Study 1: Find Repeaโ€ฆ
  2. Oct 9, 2026๐Ÿ‡ฎ๐Ÿ‡ณ ๐—š๐—ข๐—ฉ๐—˜๐—ฅ๐—ก๐— ๐—˜๐—ก๐—ง ๐—ข๐—™ ๐—œ๐—ก๐——๐—œ๐—” โ€” ๐—”๐—œ๐—–๐—ง๐—˜ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ ๐Ÿš€โ€ฆ
  3. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  4. Oct 7, 2026๐Ÿš€ DSA Topics Every Programmer Should Know ๐Ÿ’ป๐Ÿ”ฅ ๐Ÿ“ฆ 1. Arrays โœ” Traversal โœ” Searching โœ” Sorโ€ฆ
  5. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  6. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’