Object-Oriented Programming Concepts MCQ
Test your Object-Oriented Programming knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
What is a "class" in object-oriented programming?
2What is an "object" in object-oriented programming?
3What does "encapsulation" mean in OOP?
4What is "inheritance" in OOP?
5What is "polymorphism" in OOP?
6What is "abstraction" in OOP?
7What is a "constructor"?
8What is the term for a variable that belongs to an object (an instance of a class)?
9What is a "method" in OOP?
10In OOP, what is a "parent class" (or "base class")?
11What is a "child class" (or "derived class" / "subclass")?
12What does "this" (or "self") typically refer to inside an instance method?
13What is "method overriding"?
14What is "method overloading"?
15What access modifier typically makes a class member accessible only within its own class?
16What access modifier typically allows a class member to be accessed from any code that has access to the object?
17What access modifier typically allows access from the declaring class and its subclasses, but not from unrelated classes?
18What is an "interface" in OOP?
19What is an "abstract class"?
20What is "composition" in OOP?
21What is a "static" method or field?
22What is a "destructor"?
23What term describes the real-world relationship "a Car has an Engine"?
24What term describes the relationship "a Dog is an Animal"?
25What is the purpose of a "getter" method?
26What is the purpose of a "setter" method?
27In most class-based OOP languages, what keyword is commonly used to create a new object instance?
28What does it mean for a method to be "final" (or non-overridable)?
29What is a "constant" in the context of a class?
30What is the main benefit of encapsulation?
31What is a "namespace" (or "package" / "module") used for in OOP languages?
32What is "dot notation" commonly used for in OOP?
33What is the term for creating a new object from a class called?
34Which of these is an example of a real-world analogy for a class and its objects?
35Why might a class have multiple constructors with different parameters?
36What does it mean for a class to "implement" an interface?
37What is a "property" (or "field") of a class?
38In OOP, what does "is-a" describe, as opposed to "has-a"?
39What happens if a subclass does not override a method from its parent class?
40What is a key advantage of using OOP for large software systems?
What is the difference between "method overloading" and "method overriding"?
2What is "dynamic (runtime) polymorphism" typically implemented through?
3Why might a class be designed to favor composition over inheritance?
4What problem does the "diamond problem" refer to?
5What is an "abstract method"?
6What is the purpose of the "Liskov Substitution Principle" (the L in SOLID)?
7What does the "Single Responsibility Principle" (the S in SOLID) state?
8What does the "Open/Closed Principle" (the O in SOLID) state?
9What does the "Interface Segregation Principle" (the I in SOLID) state?
10What does the "Dependency Inversion Principle" (the D in SOLID) state?
11What is a "design pattern"?
12Which design pattern ensures a class has only one instance and provides a global access point to it?
13Which design pattern defines a one-to-many dependency so that when one object changes state, all its dependents are notified?
14Which design pattern provides an interface for creating objects without specifying their concrete classes?
15What is the purpose of the "Strategy" design pattern?
16What is the purpose of the "Decorator" design pattern?
17What is the purpose of the "Adapter" design pattern?
18What does "duck typing" mean (notably in languages like Python or Ruby)?
19What is a "mixin"?
20In OOP, what is a "shallow copy" of an object?
21In OOP, what is a "deep copy" of an object?
22What is "operator overloading"?
23Why are immutable objects (objects whose state cannot change after creation) often preferred in certain designs?
24What is the purpose of an abstract class's constructor if the class cannot be instantiated directly?
25What does it mean for a class to have "high cohesion"?
26What does "loose coupling" between classes mean, and why is it desirable?
27What is a "constructor chaining" (or calling another constructor from within a constructor, e.g. via super() or this())?
28What is the difference between an interface and an abstract class (in languages that support both)?
29What is "multiple inheritance"?
30What is a "virtual method" (in languages like C++ or C#)?
31What is the benefit of programming "to an interface" rather than a concrete implementation?
32What is a "factory" in the context of object creation patterns?
33What does the term "god object" (or "god class") describe as an anti-pattern?
34What does it mean to "compose" behaviors via dependency injection?
35In a class hierarchy, what is "covariant return type"?
36What is the main risk of using "protected" fields extensively in a class hierarchy?
37What is "encapsulation" most directly in tension with, if overused without any public interface?
38What is a "value object" in OOP design?
39When designing class hierarchies, why is "is-a" sometimes a misleading guide for inheritance (e.g. "a Square is-a Rectangle")?
40What is a common reason to use the "Template Method" design pattern?
What is "double dispatch" and why is it relevant to polymorphism?
2How does the "Visitor" design pattern relate to double dispatch?
3What is "object slicing" in languages like C++?
4In the context of the SOLID principles, what is a "fragile base class" problem?
5What is "mixin composition" used to solve compared to traditional multiple inheritance?
6What is the difference between "structural subtyping" and "nominal subtyping"?
7Why can excessive use of inheritance lead to violation of encapsulation, sometimes summarized as "inheritance breaks encapsulation"?
8What is "covariance" and "contravariance" as applied to method parameters and return types in OOP type systems?
9What is the purpose of the "Null Object" pattern?
10In languages supporting "generics" or "templates", how does this relate to OOP polymorphism?
11What does "favor delegation over inheritance" mean as a design heuristic?
12How do "abstract classes" and "interfaces with default methods" (e.g. Java 8+ default methods) compare in terms of evolving APIs?
13What subtle issue can arise from calling an overridable (virtual) method from within a constructor?
14What is "interface pollution" and how do SOLID principles address it?
15How does the "Open/Closed Principle" relate to the Strategy and Template Method patterns?
16In a deep inheritance hierarchy, what is the "yo-yo problem"?
17What does it mean for a method to be "idempotent" in the context of object state mutation, and why might this matter for OOP API design?
18How can "encapsulation" and "testability" sometimes conflict, and what is a common resolution?
19What is the relationship between the "Composite" design pattern and polymorphism?
20Why might overusing "static" methods and classes undermine the benefits of OOP design?