🧩

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.

100 Questions 40 Beginner 40 Intermediate 20 Advanced
1

What is a "class" in object-oriented programming?

2

What is an "object" in object-oriented programming?

3

What does "encapsulation" mean in OOP?

4

What is "inheritance" in OOP?

5

What is "polymorphism" in OOP?

6

What is "abstraction" in OOP?

7

What is a "constructor"?

8

What is the term for a variable that belongs to an object (an instance of a class)?

9

What is a "method" in OOP?

10

In OOP, what is a "parent class" (or "base class")?

11

What is a "child class" (or "derived class" / "subclass")?

12

What does "this" (or "self") typically refer to inside an instance method?

13

What is "method overriding"?

14

What is "method overloading"?

15

What access modifier typically makes a class member accessible only within its own class?

16

What access modifier typically allows a class member to be accessed from any code that has access to the object?

17

What access modifier typically allows access from the declaring class and its subclasses, but not from unrelated classes?

18

What is an "interface" in OOP?

19

What is an "abstract class"?

20

What is "composition" in OOP?

21

What is a "static" method or field?

22

What is a "destructor"?

23

What term describes the real-world relationship "a Car has an Engine"?

24

What term describes the relationship "a Dog is an Animal"?

25

What is the purpose of a "getter" method?

26

What is the purpose of a "setter" method?

27

In most class-based OOP languages, what keyword is commonly used to create a new object instance?

28

What does it mean for a method to be "final" (or non-overridable)?

29

What is a "constant" in the context of a class?

30

What is the main benefit of encapsulation?

31

What is a "namespace" (or "package" / "module") used for in OOP languages?

32

What is "dot notation" commonly used for in OOP?

33

What is the term for creating a new object from a class called?

34

Which of these is an example of a real-world analogy for a class and its objects?

35

Why might a class have multiple constructors with different parameters?

36

What does it mean for a class to "implement" an interface?

37

What is a "property" (or "field") of a class?

38

In OOP, what does "is-a" describe, as opposed to "has-a"?

39

What happens if a subclass does not override a method from its parent class?

40

What is a key advantage of using OOP for large software systems?

1

What is the difference between "method overloading" and "method overriding"?

2

What is "dynamic (runtime) polymorphism" typically implemented through?

3

Why might a class be designed to favor composition over inheritance?

4

What problem does the "diamond problem" refer to?

5

What is an "abstract method"?

6

What is the purpose of the "Liskov Substitution Principle" (the L in SOLID)?

7

What does the "Single Responsibility Principle" (the S in SOLID) state?

8

What does the "Open/Closed Principle" (the O in SOLID) state?

9

What does the "Interface Segregation Principle" (the I in SOLID) state?

10

What does the "Dependency Inversion Principle" (the D in SOLID) state?

11

What is a "design pattern"?

12

Which design pattern ensures a class has only one instance and provides a global access point to it?

13

Which design pattern defines a one-to-many dependency so that when one object changes state, all its dependents are notified?

14

Which design pattern provides an interface for creating objects without specifying their concrete classes?

15

What is the purpose of the "Strategy" design pattern?

16

What is the purpose of the "Decorator" design pattern?

17

What is the purpose of the "Adapter" design pattern?

18

What does "duck typing" mean (notably in languages like Python or Ruby)?

19

What is a "mixin"?

20

In OOP, what is a "shallow copy" of an object?

21

In OOP, what is a "deep copy" of an object?

22

What is "operator overloading"?

23

Why are immutable objects (objects whose state cannot change after creation) often preferred in certain designs?

24

What is the purpose of an abstract class's constructor if the class cannot be instantiated directly?

25

What does it mean for a class to have "high cohesion"?

26

What does "loose coupling" between classes mean, and why is it desirable?

27

What is a "constructor chaining" (or calling another constructor from within a constructor, e.g. via super() or this())?

28

What is the difference between an interface and an abstract class (in languages that support both)?

29

What is "multiple inheritance"?

30

What is a "virtual method" (in languages like C++ or C#)?

31

What is the benefit of programming "to an interface" rather than a concrete implementation?

32

What is a "factory" in the context of object creation patterns?

33

What does the term "god object" (or "god class") describe as an anti-pattern?

34

What does it mean to "compose" behaviors via dependency injection?

35

In a class hierarchy, what is "covariant return type"?

36

What is the main risk of using "protected" fields extensively in a class hierarchy?

37

What is "encapsulation" most directly in tension with, if overused without any public interface?

38

What is a "value object" in OOP design?

39

When designing class hierarchies, why is "is-a" sometimes a misleading guide for inheritance (e.g. "a Square is-a Rectangle")?

40

What is a common reason to use the "Template Method" design pattern?

1

What is "double dispatch" and why is it relevant to polymorphism?

2

How does the "Visitor" design pattern relate to double dispatch?

3

What is "object slicing" in languages like C++?

4

In the context of the SOLID principles, what is a "fragile base class" problem?

5

What is "mixin composition" used to solve compared to traditional multiple inheritance?

6

What is the difference between "structural subtyping" and "nominal subtyping"?

7

Why can excessive use of inheritance lead to violation of encapsulation, sometimes summarized as "inheritance breaks encapsulation"?

8

What is "covariance" and "contravariance" as applied to method parameters and return types in OOP type systems?

9

What is the purpose of the "Null Object" pattern?

10

In languages supporting "generics" or "templates", how does this relate to OOP polymorphism?

11

What does "favor delegation over inheritance" mean as a design heuristic?

12

How do "abstract classes" and "interfaces with default methods" (e.g. Java 8+ default methods) compare in terms of evolving APIs?

13

What subtle issue can arise from calling an overridable (virtual) method from within a constructor?

14

What is "interface pollution" and how do SOLID principles address it?

15

How does the "Open/Closed Principle" relate to the Strategy and Template Method patterns?

16

In a deep inheritance hierarchy, what is the "yo-yo problem"?

17

What 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?

18

How can "encapsulation" and "testability" sometimes conflict, and what is a common resolution?

19

What is the relationship between the "Composite" design pattern and polymorphism?

20

Why might overusing "static" methods and classes undermine the benefits of OOP design?