Object-Oriented Programming Concepts Flashcards
7 cards from real AMCAT practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Object-Oriented Programming Concepts flashcards as text
In OOP, 'composition' refers to:
Answer: A class being built from objects of other classes as parts
Composition is a 'has-a' relationship where one class contains references to objects of other classes as its components, building complex types from simpler ones.
What is the key difference between aggregation and composition in OOP?
Answer: Composition implies stronger ownership where child objects cannot exist independently; aggregation is a weaker 'uses-a' relationship
In composition, the contained objects' lifecycle is tied to the container (strong ownership), while in aggregation the contained object can exist independently of the container.
A virtual function in C++ is a member function that:
Answer: Is declared in the base class and overridden in derived classes, resolved at runtime
Virtual functions enable runtime polymorphism — the function to call is determined at runtime based on the actual object type, not the pointer or reference type.
Which design pattern ensures that only one instance of a class is created throughout the application's lifetime?
Answer: Singleton Pattern
The Singleton pattern restricts instantiation of a class to exactly one object and provides a global point of access to that instance.
Which of the following is a characteristic of a pure virtual function (in C++) or abstract method (in Java/C#)?
Answer: It must be overridden in every concrete subclass
A pure virtual / abstract method has no implementation in the base/abstract class and must be implemented by every concrete (non-abstract) derived class.
What does 'coupling' refer to in the context of OOP design?
Answer: The degree of interdependence between software modules or classes
Coupling measures how much one class knows about or depends on another; low coupling is desirable as it makes classes more independent and easier to maintain.
In OOP, the Open/Closed Principle states that software entities should be:
Answer: Open for extension and closed for modification
The Open/Closed Principle (one of the SOLID principles) means classes should be designed so new functionality can be added via extension (subclassing, interfaces) without changing existing code.