โ
OOP Interview Questions with Answers Part-5 ๐ง ๐ป
41. What is multiple inheritance?
It means a class can inherit from more than one parent class.
โ Supported in C++
โ Not directly supported in Java (handled via interfaces)
42. What are mixins?
Mixins are a way to add reusable behavior to classes without using inheritance.
โ Used in Python and JavaScript
โ Promotes code reuse
43. What is the diamond problem in inheritance?
Occurs when two parent classes inherit from a common grandparent, and a child class inherits both.
โ Creates ambiguity about which method to inherit.
44. How is the diamond problem solved in C++ or Java?
โข C++: Uses virtual inheritance
โข Java: Avoids it entirely using interfaces (no multiple class inheritance)
45. What are abstract data types in OOP?
ADTs define what operations can be done, not how.
Examples: Stack, Queue, List
โ Implementation is hidden
โ Promotes abstraction
46. What is a design pattern in OOP?
Reusable solution to a common software design problem.
โ Templates for writing clean, maintainable code
47. What are some common OOP design patterns?
โข Singleton โ one instance
โข Factory โ object creation logic
โข Observer โ event-based updates
โข Strategy โ interchangeable behavior
โข Adapter โ interface compatibility
48. Interface vs Abstract Class (Real-world use)
โข Interface โ Contract; use when you want to define capability (e.g., Drivable)
โข Abstract Class โ Shared structure + behavior; base class for similar types (e.g., Vehicle)
49. What is garbage collection?
Automatic memory management โ reclaims memory from unused objects.
โ Java has a built-in GC
โ Prevents memory leaks
50. Real-world use of OOP?
โข Games โ Objects for players, enemies
โข Banking โ Classes for accounts, transactions
โข UI โ Buttons, forms as objects
โข E-commerce โ Products, carts, users as objects
๐ฌ Double Tap โค๏ธ For More!
Post #2739
2.13K
- โค 5