Abstract Class in Object Oriented Programming (OOPs) MCQ Questions and Answers
1. An abstract class in OOP is best described as:
A) A class that cannot contain methods.
B) A class that may contain abstract methods and cannot be instantiated directly.
C) A class that has no data members.
D) A class that always has only static methods.
Answer: B
2. Which of the following statements is true about abstract methods?
A) They must have a method body.
B) They can be invoked directly without an instance.
C) They declare a method signature without implementation.
D) They are always private.
Answer: C
3. In Java, which keyword is used to declare an abstract class?
A) final
B) static
C) abstract
D) interface
Answer: C
4. Which of the following is NOT allowed in an abstract class in Java?
A) Concrete (implemented) methods
B) Instance variables
C) Constructors
D) Instantiation of the abstract class using new
Answer: D
5. How does an abstract class differ from an interface (classic pre-Java 8 view)?
A) Abstract class cannot have fields.
B) Interface can have constructors.
C) Abstract class can have implemented methods and state; interface cannot (pre-Java 8).
D) Interface can be instantiated.
Answer: C
6. Which of the following correctly describes a “pure virtual” function in C++?
A) A method that has a default implementation.
B) A non-virtual function.
C) A virtual function declared with = 0 and no implementation in the base class.
D) A function that cannot be overridden.
Answer: C
7. What happens if a subclass does not override an abstract method from its abstract superclass?
A) The subclass becomes final.
B) The subclass becomes static.
C) The subclass must be declared abstract.
D) The program will compile but fail at runtime.
Answer: C
8. Can an abstract class have a constructor?
A) No, abstract classes cannot have constructors.
B) Only default constructors.
C) Only parameterless constructors.
D) Yes, abstract classes can have constructors used by subclasses.
Answer: D
9. Which of these is a valid reason to use an abstract class?
A) To prevent any methods from being overridden.
B) To allow instantiation only for testing.
C) To force all subclasses to be final.
D) To define a common base with shared code and some required methods.
Answer: D
10. In C#, how do you declare an abstract method?
A) virtual void m();
B) sealed void m();
C) static void m();
D) public abstract void m();
Answer: D
11. Can an abstract class implement an interface?
A) No, only concrete classes can implement interfaces.
B) Only if the interface has no methods.
C) Yes — abstract class can implement (and partially implement) interfaces.
D) Only in languages with multiple inheritance.
Answer: C
12. Which of the following about abstract classes and multiple inheritance in C++ is true?
A) C++ does not allow abstract classes.
B) An abstract class cannot be a base for multiple inheritance.
C) C++ supports multiple inheritance, so abstract classes can be multiply inherited.
D) Multiple inheritance makes abstract classes concrete.
Answer: C
13. Which of the following statements is true about abstract classes and fields?
A) Abstract classes cannot have static fields.
B) Abstract classes cannot have instance fields.
C) Abstract classes can have fields to store shared state.
D) Abstract classes can only have final fields.
Answer: C
14. In Java, can an abstract class have private abstract methods?
A) Yes, private abstract methods are allowed.
B) No — abstract methods must be accessible to subclasses (not private).
C) Only if the subclass is in the same package.
D) Only if the abstract class is final.
Answer: B
15. Which design pattern often uses abstract classes to define the skeleton of an algorithm?
A) Singleton
B) Adapter
C) Template Method
D) Observer
Answer: C
16. When is an abstract class preferable to an interface?
A) When no methods need implementation.
B) When multiple inheritance is required.
C) When you need to provide common code and state to subclasses.
D) When methods must be static only.
Answer: C
17. In Java, which of these method modifiers can be applied to an abstract method?
A) final
B) private
C) static
D) public
Answer: D
18. Can an abstract class be marked final?
A) Yes, marking final prevents subclassing.
B) No — final and abstract are mutually exclusive (final prevents subclassing).
C) Only in languages that support sealed classes.
D) Yes, but only for internal classes.
Answer: B
19. What is the minimum requirement for a class to be abstract in many OOP languages?
A) It must have only static fields.
B) It must lack a constructor.
C) It must have at least one abstract method or be explicitly declared abstract.
D) It must contain only private methods.
Answer: C
20. In Python, how is an abstract base class (ABC) commonly defined?
A) Using the final decorator.
B) By inheriting from object only.
C) By inheriting from abc.ABC and using @abstractmethod.
D) Python has no support for abstract classes.
Answer: C
21. Which of the following is true about abstract properties (getters/setters) in languages that support them?
A) They cannot be abstract.
B) They always have a body.
C) Properties can be declared abstract to force subclasses to implement accessors.
D) They must be static.
Answer: C
22. If a class has a pure virtual destructor in C++, what must be provided?
A) No destructor is needed.
B) Subclasses cannot define destructors.
C) A pure virtual destructor still requires a definition (body) to run base cleanup.
D) The compiler provides a default body automatically.
Answer: C
23. Which statement about abstract classes and serialization is generally true?
A) Abstract classes cannot be serialized.
B) Abstract classes must always implement Serializable.
C) Abstract classes can be serializable; subclasses provide the concrete instances to serialize.
D) Serialization converts abstract methods to concrete ones.
Answer: C
24. In languages with access modifiers, which visibility is common for abstract methods to allow overriding?
A) private
B) protected or public
C) static
D) final
Answer: B
25. Which of the following can an abstract class contain?
A) Only abstract methods and nothing else.
B) No constructors.
C) Abstract methods, concrete methods, fields, and constructors.
D) Only static members.
Answer: C
26. How does polymorphism relate to abstract classes?
A) Abstract classes prevent polymorphism.
B) Polymorphism requires interfaces only.
C) Abstract classes provide polymorphic behavior via overridden methods.
D) Abstract classes always use compile-time binding.
Answer: C
27. Can abstract classes be generic (parameterized) in languages like Java and C#?
A) No, abstract classes cannot be generic.
B) Only interfaces can be generic.
C) Yes — abstract classes may be declared with type parameters.
D) Only static classes can be generic.
Answer: C
28. What will happen if you try to instantiate an abstract class directly?
A) It will succeed at runtime.
B) It will compile but throw at runtime.
C) Compiler error / language-specific compile-time rejection.
D) It creates an instance of a proxy class automatically.
Answer: C
29. Which of these is a language where abstract classes are a primary OOP mechanism?
A) SQL
B) HTML
C) Java
D) CSS
Answer: C
30. In Java, can an abstract class declare static methods?
A) No, abstract classes cannot have static methods.
B) Static methods must be abstract.
C) Yes — static methods are allowed and may be called without an instance.
D) Only if they are final.
Answer: C
31. How are abstract classes related to code reuse?
A) They prevent code reuse.
B) They duplicate code among subclasses.
C) They enable reuse by providing shared implementations for subclasses.
D) They require all code to be implemented in subclasses.
Answer: C
32. In languages that support sealed or final classes, what is an effect of sealing an abstract class?
A) It allows more subclasses.
B) It makes abstract methods concrete automatically.
C) It restricts which classes may subclass it.
D) It allows instantiation.
Answer: C
33. Which one of these is NOT a valid characteristic of abstract classes?
A) Can declare abstract methods.
B) Can provide default implementations.
C) Can be instantiated directly.
D) Can require subclasses to override methods.
Answer: C
34. In UML, how is an abstract class usually denoted?
A) With a red outline.
B) By italicizing the class name.
C) By a dashed border.
D) By italicizing the class name or noting <>.
Answer: D
35. Consider a language where methods are virtual by default. If a base class has an abstract method, what binding is used when invoked through a base pointer?
A) Static binding.
B) Dynamic (runtime) binding / late binding.
C) Macro expansion.
D) Compile-time inlining.
Answer: B
36. In Java, can an abstract class be used as a parameter type?
A) No — only concrete classes can be parameter types.
B) Yes — abstract classes can be used as reference types for parameters.
C) Only if it implements Serializable.
D) Only in nested classes.
Answer: B
37. What is the effect of declaring a method abstract in the superclass?
A) It prevents subclasses from overriding it.
B) It provides a default behavior.
C) It forces subclasses to supply an implementation or be abstract.
D) It makes the method private.
Answer: C
38. In languages where both interfaces and abstract classes exist, which can provide constructors?
A) Interfaces only.
B) Abstract classes only.
C) Both interfaces and abstract classes.
D) Neither can provide constructors.
Answer: B
39. Which of the following is true about abstract static methods in Java?
A) Abstract static methods are allowed and must be overridden.
B) Abstract static methods are not allowed — static methods cannot be abstract.
C) Static methods are abstract by default.
D) They behave like instance abstract methods.
Answer: B
40. If a class extends an abstract class and provides implementations for all abstract methods, what is its type?
A) It must also be abstract.
B) It can be a concrete (non-abstract) class and instantiated.
C) It becomes an interface.
D) It must be final.
Answer: B
41. Which of these scenarios best fits using an abstract class?
A) When you only need constants and no behavior.
B) When multiple related classes share behavior and must implement certain methods.
C) When you need to create exactly one instance only.
D) When you require lightweight data-only structures.
Answer: B
42. Are abstract methods inherited by subclasses?
A) No, they are private to the superclass.
B) Yes — subclasses inherit abstract methods and must implement or remain abstract.
C) Only in interfaces.
D) Only if declared final.
Answer: B
43. In C++, which declaration makes a class abstract?
A) Including only private members.
B) Defining a non-virtual method.
C) Declaring at least one pure virtual function (virtual … = 0).
D) Declaring a virtual destructor only.
Answer: C
44. Can an abstract class contain final methods (methods that cannot be overridden)?
A) No, abstract classes cannot contain final methods.
B) Yes — an abstract class may contain final concrete methods.
C) Only if marked static.
D) Only in interfaces.
Answer: B
45. If a method is declared abstract, can it be static in Java?
A) Yes, static abstract methods are common.
B) No — abstract methods cannot be static in Java.
C) Only in inner classes.
D) Only when final.
Answer: B
46. What is a common compile-time benefit of using abstract classes?
A) Increased runtime performance.
B) Enforcing API contracts and detecting missing implementations at compile-time.
C) Reducing binary size.
D) Hiding all methods from subclasses.
Answer: B
47. In Scala, how are abstract classes declared?
A) Using the keyword interface.
B) Using the keyword abstract class.
C) By marking a class final.
D) Scala does not support abstract classes.
Answer: B
48. Which of the following is true regarding method overriding of an abstract method?
A) Overriding method must have lesser visibility.
B) Overriding method cannot change signature.
C) Overriding method must match signature and can widen access.
D) Overriding method must be static.
Answer: C
49. Can abstract classes be used to define callback handlers?
A) No, callbacks require interfaces only.
B) Yes — abstract classes can define callback methods that subclasses implement.
C) Only in functional languages.
D) Only when the callback has no parameters.
Answer: B
50. In languages with single inheritance (like Java), how do abstract classes limit extensibility compared to interfaces?
A) They allow multiple inheritance.
B) They prevent a class from extending another abstract class if it already extends one (single inheritance constraint).
C) They can be implemented by multiple classes.
D) They have no effect on extensibility.
Answer: B
51. Which of the following best describes an “abstract data type” vs. “abstract class”?
A) They are identical concepts.
B) Abstract class is language-level; abstract data type is a conceptual model of operations and behavior.
C) Abstract data type is conceptual; abstract class is a concrete language construct implementing abstraction.
D) Abstract data type is only for functional languages.
Answer: C
52. In Java, what modifier combination is illegal for an abstract method?
A) public abstract
B) protected abstract
C) private abstract
D) abstract default (default is not a modifier for methods)
Answer: C
53. Which of the following correctly describes abstract class constructors?
A) They cannot call super.
B) They are used to initialize state for subclasses.
C) Constructors of abstract classes are never invoked.
D) Constructors of abstract classes are invoked as part of subclass instantiation to initialize inherited state.
Answer: D
54. What is the primary role of an abstract base class in a class hierarchy?
A) To provide complete implementation only.
B) To prevent subclassing.
C) To define a common interface and possibly share some implementation.
D) To act as a replacement for interfaces always.
Answer: C
55. Can abstract classes declare constants?
A) No constants allowed.
B) Only in the form of enums.
C) Yes, abstract classes can declare constants (static final fields).
D) Only if they are public.
Answer: C
56. Which of these is a risk of overusing abstract classes?
A) Increased testability.
B) Rigid hierarchies and reduced flexibility for composition or multiple inheritance.
C) Faster development.
D) Reduced coupling.
Answer: B
57. How does the Template Method pattern use abstract classes?
A) It uses them to prevent subclassing.
B) Abstract classes are not involved.
C) It defines the skeleton of an algorithm in the abstract class, with steps implemented or deferred to subclasses.
D) It replaces interfaces entirely.
Answer: C
58. In Java 8+, interfaces can have default methods. How does that affect abstract classes?
A) Interfaces replace abstract classes completely.
B) Interfaces gain ability to include behavior, reducing some previous advantages of abstract classes.
C) Abstract classes can no longer have methods.
D) Interfaces now can be instantiated.
Answer: B
59. In C++, if a class contains a pure virtual function, can it still have implemented non-virtual functions?
A) No, all functions must be virtual.
B) Yes — it can have non-virtual implemented functions.
C) Only if they are inline.
D) Only in the derived class.
Answer: B
60. Which of the following is true about abstract classes and unit testing?
A) Abstract classes cannot be tested.
B) Abstract classes may be tested via concrete test subclasses or mocking frameworks.
C) Abstract classes always fail tests.
D) Abstract classes must be converted to interfaces to test.
Answer: B
61. In a language with multiple dispatch, how relevant are abstract classes for polymorphism?
A) Not relevant at all.
B) They remain relevant for defining common behavior but dispatch semantics differ.
C) They are replaced by enums.
D) Abstract classes force single dispatch.
Answer: B
62. Which of the following is a valid criticism of abstract classes?
A) They are always slower than interfaces.
B) They can cause deep inheritance trees and tight coupling when overused.
C) They never allow default behavior.
D) They require all methods to be static.
Answer: B
63. Can an abstract class be used to provide backward-compatible API evolution?
A) No, only interfaces can.
B) Yes — abstract classes can add concrete methods while preserving required abstract methods for subclasses.
C) Only by removing methods.
D) Only if they are final.
Answer: B
64. In Java, which of these is true about an abstract class with no abstract methods?
A) It is illegal and will not compile.
B) It is allowed — a class can be declared abstract even without abstract methods.
C) It becomes an interface automatically.
D) It must be final.
Answer: B
65. What does it mean when a method is declared virtual and not overridden?
A) The subclass hides the base method.
B) The base class implementation is used at runtime if not overridden.
C) The program will not compile.
D) The method becomes abstract.
Answer: B
66. Which statement about abstract classes and reflection is usually true?
A) Abstract classes cannot be inspected via reflection.
B) Reflection can inspect abstract classes and their methods; instantiation requires concrete subclass or special mechanisms.
C) Reflection makes abstract methods concrete.
D) Reflection always fails on abstract classes.
Answer: B
67. In Java, can an abstract class extend another abstract class?
A) No — abstract classes cannot extend classes.
B) Yes — abstract classes can extend other abstract or concrete classes.
C) Only interfaces can be extended.
D) Only with final modifier.
Answer: B
68. Which of the following best practices applies to abstract classes?
A) Always make all methods abstract.
B) Use them only for one-off utilities.
C) Prefer small, focused abstract classes that encapsulate shared behavior and clear contracts.
D) Replace all interfaces with abstract classes.
Answer: C
69. Which of these is NOT a reason to declare a class abstract?
A) To force subclasses to implement a method.
B) To share common code among subclasses.
C) To allow direct instantiation of that class.
D) To represent a conceptual base type.
Answer: C
70. In languages with traits or mixins, what role do abstract classes play compared to traits?
A) Traits always replace abstract classes.
B) Abstract classes provide base class behavior and state; traits provide composable behavior without a single inheritance constraint.
C) Abstract classes are the only way to achieve polymorphism.
D) Traits cannot provide method implementations.
Answer: B
71. Can abstract classes declare synchronized methods (in languages that support synchronization)?
A) No, only concrete classes can be synchronized.
B) Yes — abstract classes can declare synchronized concrete methods.
C) Abstract methods can be synchronized.
D) Synchronization prevents abstraction.
Answer: B
72. If a base abstract class provides a final method, what is the effect on subclasses?
A) Subclasses must override it.
B) Subclasses cannot see the method.
C) Subclasses cannot override that final method; they inherit the behavior as-is.
D) The method becomes abstract in subclasses.
Answer: C
73. Which of the following is true regarding abstract nested (inner) classes?
A) Inner classes cannot be abstract.
B) Inner classes may be abstract and provide base behavior for nested hierarchies.
C) Nested classes must be static to be abstract.
D) Abstract nested classes automatically become interfaces.
Answer: B
74. In languages that allow mix of abstract methods and implemented methods, what is a key advantage?
A) Reducing runtime polymorphism.
B) Providing default behavior while requiring critical methods to be implemented by subclasses.
C) Forcing use of global variables.
D) Preventing unit testing.
Answer: B
75. Which of the following is true about abstract classes and dependency injection?
A) Abstract classes cannot be injected.
B) Abstract classes can serve as injection types for concrete implementations.
C) Dependency injection requires interfaces only.
D) Abstract classes break inversion of control.
Answer: B
76. In Java, what happens if a class implements an interface and extends an abstract class that both declare the same method signature?
A) The code will not compile.
B) The class must provide a concrete implementation or inherit one; conflicts are resolved by concrete implementation precedence.
C) Interfaces always win over abstract classes.
D) The method becomes ambiguous at runtime.
Answer: B
77. Which of these is a correct statement about abstract classes and memory layout?
A) Abstract classes always increase object size.
B) Abstract classes contribute only via fields they declare; abstractness alone does not change instance memory layout beyond inherited fields.
C) Abstract methods consume extra memory per instance.
D) Abstract classes store method bodies per instance.
Answer: B
78. What is an abstract factory in relation to abstract classes?
A) An abstract class that cannot be extended.
B) A design pattern using interfaces or abstract classes to create families of related objects.
C) A factory that constructs only abstract classes.
D) A framework feature unrelated to abstraction.
Answer: B
79. Can abstract classes be used to enforce security constraints in APIs?
A) No, abstract classes are unrelated to security.
B) Yes — abstract classes can provide controlled access to methods and guard common behavior.
C) Only interfaces can enforce security.
D) Abstract classes always reduce security.
Answer: B
80. In languages with annotations/attributes, can abstract methods be annotated?
A) No annotations allowed on abstract methods.
B) Yes — annotations can document or change behavior of abstract methods for tooling.
C) Only if they are public.
D) Annotations make methods concrete.
Answer: B
81. Which of the following is a consequence of declaring a class abstract in a public API?
A) It forces all clients to extend the class.
B) It signals intended inheritance and allows extension points for clients.
C) It prevents any further evolution of the API.
D) It will cause runtime exceptions in all clients.
Answer: B
82. In languages that disallow fields in interfaces, how can abstract classes help?
A) They cannot help.
B) Abstract classes can hold shared fields and implementations that interfaces cannot.
C) By converting fields into methods only.
D) By preventing subclassing.
Answer: B
83. Which of these is true for an abstract class used as a plugin base?
A) It cannot be extended outside the package.
B) Plugins require concrete classes only.
C) It defines lifecycle methods and some default behavior to be overridden by plugins.
D) Plugin frameworks always require interfaces, not abstract classes.
Answer: C
84. Are abstract classes always part of inheritance hierarchies only?
A) Yes — they cannot be used in composition.
B) While primarily for inheritance, abstract classes can also be used as types in composition.
C) They must be top-level only.
D) They are only compile-time artifacts with no runtime presence.
Answer: B
85. In unit testing, what is a common technique to test abstract class behavior?
A) Ignoring abstract class code.
B) Create a lightweight concrete subclass (test double) that implements abstract methods for testing.
C) Convert abstract class to interface temporarily.
D) Use only integration tests.
Answer: B
86. Which of the following statements about abstract classes and backwards compatibility is correct?
A) Adding abstract methods to an abstract class is always safe.
B) Adding new abstract methods is breaking for existing subclasses; adding concrete methods is usually safe.
C) Removing methods is always safe.
D) Changing access modifiers never affects compatibility.
Answer: B
87. In languages with default method implementations in interfaces, one reason to prefer abstract classes is:
A) Interfaces are always slower.
B) Abstract classes can hold state (fields) in addition to behavior.
C) Interfaces cannot be implemented by multiple classes.
D) Abstract classes can be instantiated.
Answer: B
88. Which of these is true about abstract final combination in Java?
A) You can declare a class both abstract and final.
B) No — abstract and final are contradictory (abstract requires subclassing; final prevents it).
C) It makes the class instantiable.
D) It makes all methods abstract implicitly.
Answer: B
89. Which of the following describes an abstract adapter class pattern?
A) A class that implements nothing.
B) A concrete class with only static methods.
C) An abstract class providing empty/default implementations of an interface to simplify subclassing.
D) A way to prevent inheritance.
Answer: C
90. For performance-critical code, what must be considered with abstract methods?
A) Abstract methods are always inlined.
B) Virtual dispatch adds small overhead; measure if critical and consider alternatives if needed.
C) Abstract methods are compiled away.
D) Abstract methods always optimize to constants.
Answer: B
91. In object serialization, how can abstract classes complicate deserialization?
A) Abstract classes never participate in deserialization.
B) Deserialization requires concrete subclass types to instantiate; factory or type metadata may be needed.
C) Serialization always converts abstract methods.
D) Abstract classes become concrete during deserialization automatically.
Answer: B
92. Which of the following is true regarding abstract classes and documentation?
A) Abstract classes should never be documented.
B) Abstract classes are useful to document extension points and required subclass behavior.
C) Documentation only belongs to concrete classes.
D) Abstract classes cannot have Javadoc or comments.
Answer: B
93. Which statement about abstract interface methods and abstraction is generally true?
A) Abstract methods in classes always provide default impl.
B) Both abstract interface methods and abstract class methods express required behavior, but abstract classes may also provide implementation.
C) Interfaces cannot express required behavior.
D) Abstract class methods cannot be overridden.
Answer: B
94. In a language with single inheritance but multiple interface implementation, what is an architectural guideline?
A) Always use abstract classes for everything.
B) Prefer interfaces for role definitions and abstract classes for shared implementation/state.
C) Avoid interfaces completely.
D) Multiple inheritance solves all problems.
Answer: B
95. Which of the following is true about abstract class fields access?
A) Subclasses cannot access protected fields.
B) Protected fields in an abstract class are accessible to subclasses for shared state.
C) Abstract class fields are always private.
D) Abstract classes cannot have transient fields.
Answer: B
96. What should you consider when designing an abstract base class for a framework?
A) Make everything abstract to force users to implement all methods.
B) Provide clear contracts, minimal necessary abstract methods, and sensible default implementations.
C) Use private abstract methods for flexibility.
D) Prevent any subclassing.
Answer: B
97. In C++, how does an abstract class affect object slicing?
A) Abstract classes prevent slicing entirely.
B) Slicing is a risk when copying derived objects into base objects; abstractness does not eliminate slicing — use pointers/references.
C) Abstract classes make slicing safe.
D) Object slicing only occurs with interfaces.
Answer: B
98. Which of these is correct regarding abstract class method visibility and overriding in Java?
A) The overriding method can have more restrictive visibility.
B) The overriding method cannot reduce visibility; it may widen visibility.
C) Visibility rules do not apply to overridden methods.
D) Overriding methods must be private.
Answer: B
99. Which of the following best captures a migration strategy from abstract classes to interfaces with default methods?
A) Convert everything and remove abstract classes immediately.
B) Gradually add default methods to interfaces while keeping abstract classes where shared state is needed.
C) Interfaces cannot be modified so migration is impossible.
D) Remove all implementations and use only interfaces with no defaults.
Answer: B
100. Which of the following correctly lists a limitation of abstract classes compared to mixins/traits?
A) Abstract classes give more composability.
B) Abstract classes are limited by single inheritance (in many languages), while traits/mixins allow composition of behavior without strict inheritance.
C) Abstract classes cannot declare methods.
D) Traits are always slower.
Answer: B
