DATA ABSTRACTION AND PROBLEM SOLVING WITH C++ MULTICHOICE
ANSWERED EXAM QUESTIONS WITH DETAILED RATIONALES
1. Object-Oriented Analysis and Design (OOAD) is best described as:
A. A set of programming language syntax rules
B. A database modeling technique
C. A process for solving problems ✅
D. A protocol for networking
Rationale: OOAD is a problem-solving process that uses object-oriented concepts to
analyze and design software solutions.
2. Object-Oriented Analysis primarily focuses on:
A. Writing efficient source code
B. Understanding the problem and the solution requirements ✅
C. Optimizing runtime performance
D. Generating deployment scripts
Rationale: OO analysis seeks to discover what the system must do (requirements), not
how to implement it.
3. Encapsulation in OOP refers to:
A. Allowing multiple classes to inherit a single method
B. Hiding inner details (data and implementation) behind an interface ✅
C. Converting procedural code into objects automatically
D. Duplicating class definitions across modules
Rationale: Encapsulation packages data and methods and hides internal representation
from external access.
4. Inheritance allows you to:
A. Forcefully override unrelated classes
B. Reuse and extend classes by deriving new classes from existing ones ✅
C. Encrypt class methods for security
D. Convert runtime objects into text files
Rationale: Inheritance enables new classes to reuse and specialize behavior of parent
classes.
5. Polymorphism means that:
A. All objects must be the same type at compile time
B. Methods cannot be overridden
C. Objects choose the appropriate operation implementation at runtime ✅
,ESTUDYR
D. There is only one implementation for every method
Rationale: Polymorphism (e.g., dynamic dispatch) lets the runtime select the correct
method for an object’s actual type.
6. An operation contract documents:
A. The programming language used for a method
B. How a method is used and its limitations (preconditions, postconditions, effects) ✅
C. The memory layout of a class instance
D. The keyboard shortcuts for the IDE
Rationale: Operation contracts specify a method’s behavior: what it requires, what it
ensures, and side effects.
7. A method’s interface specifies:
A. The algorithmic complexity of the method
B. How to call the method—number, order, and types of arguments ✅
C. Where to store the compiled object file
D. The author of the method
Rationale: The method interface (signature) tells callers what parameters and return
type to use.
8. Header files in C/C++ are used to:
A. Execute binary code directly
B. Store compiled bytecode only
C. Separate a class’s design (declarations) from its implementation (.cpp) ✅
D. Replace unit tests
Rationale: Header files contain declarations (interfaces), while source files contain
definitions/implementations.
9. An Abstract Data Type (ADT) is:
A. A physical device for storing data
B. A collection of data plus the set of operations on that data ✅
C. A specific programming language library
D. A syntax for markup languages
Rationale: An ADT defines data and the operations available without revealing
implementation.
10. The advantage of using an ADT is:
A. Faster compilation times always
B. You can use operations by their specs without knowing internal implementation ✅
C. It prevents any future changes to code
, ESTUDYR
D. It automatically generates GUIs
Rationale: ADTs provide an abstraction barrier; callers rely on specifications, enabling
independent implementation changes.
11. A constructor’s role in a class is to:
A. Compile the class into machine code
B. Allocate/initialize a new instance’s memory and initial data ✅
C. Destroy instances when they go out of scope
D. Encrypt object fields
Rationale: Constructors create and set up object state when instances are made.
12. A destructor (deconstructor) is used to:
A. Start a new thread for the object
B. Serialize an object to JSON
C. Destroy an instance and release resources when its lifetime ends ✅
D. Convert the object into an ADT
Rationale: Destructors free resources (memory, file handles) before an object is
reclaimed.
13. A mutator method typically:
A. Returns the class definition as a string
B. Changes the value of a data field (often named setX) ✅
C. Encrypts object methods
D. Makes the object immutable
Rationale: Mutators (setters) modify internal state; accessors (getters) read it.
14. Which statement about namespaces is correct?
A. Namespaces encrypt class data for security
B. Namespaces automatically generate constructors
C. A method defined in a namespace has access to names within that namespace
(avoids name collisions) ✅
D. Namespaces only apply to Python modules
Rationale: Namespaces group identifiers and prevent global name clashes; code inside
can refer to names in that namespace.
15. In C++ templates like PlainBox<ItemType>, the <ItemType> indicates:
A. A pointer to a memory address
B. A template parameter enabling the class/method to be parameterized by type ✅
C. An inheritance relationship
D. A runtime type cast operator