CSE 240 MIDTERM MOCK TEST WITH ANSWER
RATIONALES 2026
◉ If the relation between two C++ classes can be best described as
"is-a" relation, we should
A.
contain one class in the other (containment).
B.
define them to be independent of each other.
C.
derive one class from the other (inheritance).
D.
merge them into a single class.
Answer: C.
derive one class from the other (inheritance)
,◉ Consider C++'s typing system. C++ uses (Select all correct
answers)
A. value semantics for its primitive types (such as integer and float)
only.
B. both value semantics and reference semantics for its object types.
C. both value semantics and reference semantics for its primitive
types .
D. reference semantics for its object types only.
Answer: B.
both value semantics and reference semantics for its object types.
C.
both value semantics and reference semantics for its primitive types
.
◉ What does the following line of code define?
Days operator++(int)
,An overloaded operator *
A new class Days.
a new int type.
Answer: An overloaded operator ++
◉ What does the following line of code define?
bool operator>(const Cylinder &c)
A virtual function Cylindarer
An overloaded operator >
An overloaded operator &
An overloaded function Cylinder
Answer: An overloaded operator >
◉ You can define two overloading operations with the same
operator name, but with different parameter types.
, True
False
Answer: True
◉ Which statements or operations will call the destructor of a class?
Select all that apply.
throw;
delete;
try;
catch;
Answer: throw;
delete;
◉ What type of values can a throw-statement throw (return)
RATIONALES 2026
◉ If the relation between two C++ classes can be best described as
"is-a" relation, we should
A.
contain one class in the other (containment).
B.
define them to be independent of each other.
C.
derive one class from the other (inheritance).
D.
merge them into a single class.
Answer: C.
derive one class from the other (inheritance)
,◉ Consider C++'s typing system. C++ uses (Select all correct
answers)
A. value semantics for its primitive types (such as integer and float)
only.
B. both value semantics and reference semantics for its object types.
C. both value semantics and reference semantics for its primitive
types .
D. reference semantics for its object types only.
Answer: B.
both value semantics and reference semantics for its object types.
C.
both value semantics and reference semantics for its primitive types
.
◉ What does the following line of code define?
Days operator++(int)
,An overloaded operator *
A new class Days.
a new int type.
Answer: An overloaded operator ++
◉ What does the following line of code define?
bool operator>(const Cylinder &c)
A virtual function Cylindarer
An overloaded operator >
An overloaded operator &
An overloaded function Cylinder
Answer: An overloaded operator >
◉ You can define two overloading operations with the same
operator name, but with different parameter types.
, True
False
Answer: True
◉ Which statements or operations will call the destructor of a class?
Select all that apply.
throw;
delete;
try;
catch;
Answer: throw;
delete;
◉ What type of values can a throw-statement throw (return)