What is polymorphism?
A Many variables of one type
B One interface, multiple implementations
C Only one class per program
D A method with no return
Answer: B. One interface, multiple implementations. Polymorphism lets a common interface represent objects with different implementations.
What is method overriding?
A Method name, new parameters
B A method calls itself
C Field hides class
D Subtype replaces inherited method behavior
Answer: D. Subtype replaces inherited method behavior. Overriding supplies a new implementation for an inherited method signature.
What is method overloading?
A Subtype replaces base method
B Same name, different parameters
C A method without a body
D Creating several objects at once
Answer: B. Same name, different parameters. Overloading defines multiple methods with the same name but different parameter signatures.
When is overload selection often determined?
A Only after program exits
B At compile time
C By network response
D During garbage collection
Answer: B. At compile time. Many languages resolve overloaded method calls using static types and arguments at compile time.
What is dynamic dispatch?
A Choose overridden method at runtime
B Sort methods alphabetically
C Create object fields lazily
D Convert class to a file
Answer: A. Choose overridden method at runtime. Dynamic dispatch selects an implementation based on the object's runtime type.
What is a virtual method in languages like C++?
A Runtime overridable method
B Method with no parameters
C Method stored on disk
D Method available only in constructor
Answer: A. Runtime overridable method. Virtual methods participate in dynamic dispatch through base class references.
What is an abstract class?
A Class not directly instantiated
B Class with all public fields
C Class without inheritance
D Class with only static methods
Answer: A. Class not directly instantiated. An abstract class represents a partial design and cannot be instantiated directly in many languages.
What is an abstract method?
A Method always without value
B Private constructor
C Method declared without full implementation
D Method called only once
Answer: C. Method declared without full implementation. An abstract method requires a concrete implementation in a nonabstract subtype.
What is an interface?
A Object's private memory
B Contract of supported operations
C Class with required fields
D A runtime stack frame
Answer: B. Contract of supported operations. An interface specifies operations a class agrees to provide.
What is multiple inheritance?
A Object has multiple fields
B Class derives from multiple bases
C Method has multiple parameters
D Program runs multiple threads
Answer: B. Class derives from multiple bases. Multiple inheritance derives one class from more than one base class.
What is an overriding method's signature?
A Method name and parameter types
B Return value only
C Class name and fields
D Source file name
Answer: A. Method name and parameter types. A signature typically includes a method name and its parameter types.
What is a covariant return type?
A Method returns two values
B A parameter becomes optional
C Return type changes per call
D Override returns subtype
Answer: D. Override returns subtype. Some languages allow an override to return a subtype of the base method's return type.
What does super or base refer to?
A Parent class functionality
B Current object's fields only
C A global namespace
D A private helper function
Answer: A. Parent class functionality. A super or base reference provides access to superclass behavior.
What is a final or sealed class?
A Class that must be abstract
B Class with no methods
C Class that cannot be subclassed
D Class instantiated only once
Answer: C. Class that cannot be subclassed. A sealed class restricts inheritance by preventing further subclasses.
What is a final method in some languages?
A Method with no implementation
B Static method only
C Constructor with no arguments
D Method that cannot be overridden
Answer: D. Method that cannot be overridden. A final method prevents subclasses from replacing its implementation.
What does substitutability require?
A Base class must inherit subtype
B Every method must be static
C Objects must share addresses
D Subtype replaces base type
Answer: D. Subtype replaces base type. A subtype should preserve expectations when used wherever its base type is accepted.
What is a type cast in OOP?
A Copy object into a file
B Rename a class
C View value as another type
D Change a method's visibility
Answer: C. View value as another type. A cast converts or views a value through another type, subject to compatibility.
What is an upcast?
A Convert base to subtype unchecked
B Convert object to string
C Subtype reference to base
D Change a private field
Answer: C. Subtype reference to base. An upcast views a derived object through its base type interface.
What is a downcast?
A Convert subtype to base type
B Convert base reference toward subtype
C Convert a class to interface
D Call a parent constructor
Answer: B. Convert base reference toward subtype. A downcast attempts to treat a base reference as a more specific subtype.
Why check a downcast at runtime?
A Base classes have no methods
B Fields always become null
C Object may not match subtype
D The compiler cannot read classes
Answer: C. Object may not match subtype. A checked downcast verifies that the referenced object has the requested runtime type.
What is interface segregation about?
A Small focused interfaces
B One large universal interface
C Interfaces with no methods
D Interfaces used only by constructors
Answer: A. Small focused interfaces. Clients should not depend on methods they do not need.
What does dependency inversion favor?
A Depend on concrete details only
B Avoid all interfaces
C Depend on abstractions
D Make every dependency global
Answer: C. Depend on abstractions. High level logic should depend on stable abstractions rather than low level details.
What is a mixin commonly used for?
A Share reusable behavior
B Store unique object state only
C Create a database table
D Sort subclass instances
Answer: A. Share reusable behavior. A mixin supplies reusable behavior that classes can include or compose.
What is duck typing?
A Compatibility only by class name
B Runtime type always hidden
C A method with no arguments
D Compatibility based on supported behavior
Answer: D. Compatibility based on supported behavior. Duck typing focuses on whether an object supports required operations.
What is an object reference?
A Object's source code
B A class's method list
C A constructor return type
D Handle pointing to an object
Answer: D. Handle pointing to an object. A reference designates an object so code can access it.