Object-Oriented Programming MCQs (Set-4)

What does the single responsibility principle encourage?

A One reason to change
B One method in every class
C One object in each program
D One base for all types

What does the Liskov substitution principle require?

A Subtypes remove all base methods
B Subtypes preserve base expectations
C Every class inherits one base
D Base types depend on subtypes

What does interface segregation recommend?

A Large interface for all clients
B Several focused client interfaces
C No interfaces in a system
D Interfaces with private methods only

What does dependency inversion recommend?

A All code uses concrete classes
B High level depends on abstractions
C Subclasses call global state
D Interfaces depend on objects only

What is a UML class diagram used to show?

A Program execution time
B Memory bytes at runtime
C Classes and their relationships
D Only user interface colors

What does a UML inheritance arrow indicate?

A Object composition only
B Method parameter flow
C A runtime exception
D Generalization relationship

What does a multiplicity such as 1..* express?

A Method return type
B Allowed relationship count
C Class memory size
D Inheritance depth

What is a sequence diagram used to show?

A Messages over time
B Class fields by visibility
C Object memory layout
D Only data types

What is a unit test for an object class?

A Compile all project files only
B Test network throughput
C Test class behavior alone
D Measure source lines

What is a mock object?

A Production singleton instance
B Subclass constructor only
C Object's deep copy
D Test double simulating collaborator

What is a code smell?

A Sign of possible design problem
B Guaranteed compiler error
C A required design pattern
D A runtime object address

Why prefer composition over deep inheritance in many designs?

A It reduces rigid coupling
B It prevents code reuse
C It removes all interfaces
D It guarantees zero bugs

What is the fragile base class problem?

A Base change unexpectedly breaks subclasses
B Base classes cannot contain methods
C Subclass cannot override anything
D Constructor always runs twice

What does a sealed hierarchy help control?

A How objects are allocated
B Which fields are mutable
C Which types may extend it
D How constructors are named

What is an abstract factory used to create?

A A single primitive value
B One sorted list
C A runtime call stack
D Related families of objects

What does the adapter pattern do?

A Adds behavior by wrapping
B Notifies observers of change
C Makes incompatible interfaces work together
D Selects one algorithm at runtime

What does the facade pattern provide?

A A subtype with no fields
B A copy of every object
C A method's return value
D Simplified interface to subsystem

What does the command pattern encapsulate?

A Request as an object
B Object state as a field
C Class name as a string
D Inheritance as a graph

What does the template method pattern define?

A A family of factory objects
B One global instance
C Algorithm skeleton in base class
D A mutable list of observers

What does the builder pattern help construct?

A One method through inheritance
B Complex objects step by step
C Graph edges in sorted order
D Objects without constructors ever

Why use immutable value objects?

A Faster mutation in every case
B Avoid all constructors
C Allow global state changes
D Safer sharing and predictable state

What is an object's lifecycle?

A Only method invocation order
B Compilation and linking
C Sorting and searching phases
D Creation, use, and cleanup stages

What does polymorphic behavior enable?

A Generic code for many subtypes
B One concrete class only
C No method calls at runtime
D All fields public

What is a design pattern?

A A programming language keyword
B A compiler optimization
C Reusable design template
D A required class diagram

What is a bounded context in domain design?

A Class field size limit
B Model boundary with shared meaning
C Maximum method parameter count
D A test case range