COP 3330 EXAM 2 MOCK TEST WITH
ANSWER RATIONALES 2026
◉ If there is no initialization, what is being used?
Answer: The default constructor
◉ Are you allowed to call constructors in the bounds ( {} ) of an
Array?
Answer: True
Example:
Fraction nums[3] = { Fraction(2,3), Fraction(6), Fraction() };
◉ Can an Array be member data of a class?
Answer: True
◉ What should you use if an array isn't always full?
Answer: Use a tracking variable to track how many slots are being
used
◉ What are the benefits of having array member data?
,Answer: It is good for using types that use arrays, but it also adds in
safeties, like boundary checking, in member functions
◉ What are the two categories of Memory Allocation?
Answer: Static and Dynamic memory
◉ What happens with Static Memory allocation?
Answer: Static -- compile time. size and types known in advance
You set a specific size that cannot be changed after compiling stage
◉ What happens with Dynamic Memory allocation?
Answer: Dynamic -- run time. sizes and amounts can be set while
program running
Size and amounts are unknown before runtime, but can be changed
to fit the accurate size
◉ How do you create dynamic space?
Answer: You can create dynamic space with the "new" operator
Always use the TYPE after the word "new" (Ex: new INT)
◉ What does the new operator do past creating dynamic space?
, Answer: It returns the address of the allocated space, which can
(and should) use a pointer to store the address
◉ What can be dynamically allocated?
Answer: basic variables, objects, and arrays
Examples:
double* dptr = new double; int * list = new int[size]; Fraction* fptr1
= new Fraction; // uses default constructor Fraction* fptr2 = new
Fraction(1,2); // constructor with params Date* birthdayList = new
Date[20]; // array of Date objects
◉ Can you pass in a dynamically allocated object as a parameter in a
constructor?
Answer: True
◉ How do you deallocate dynamic memory?
Answer: use the "delete" operator
If you use a pointer, apply "delete" to the pointer, and it de-allocates
the target (Ex: delete pointer;)
If you use a dynamic array, use "delete [ ] pointername"
ANSWER RATIONALES 2026
◉ If there is no initialization, what is being used?
Answer: The default constructor
◉ Are you allowed to call constructors in the bounds ( {} ) of an
Array?
Answer: True
Example:
Fraction nums[3] = { Fraction(2,3), Fraction(6), Fraction() };
◉ Can an Array be member data of a class?
Answer: True
◉ What should you use if an array isn't always full?
Answer: Use a tracking variable to track how many slots are being
used
◉ What are the benefits of having array member data?
,Answer: It is good for using types that use arrays, but it also adds in
safeties, like boundary checking, in member functions
◉ What are the two categories of Memory Allocation?
Answer: Static and Dynamic memory
◉ What happens with Static Memory allocation?
Answer: Static -- compile time. size and types known in advance
You set a specific size that cannot be changed after compiling stage
◉ What happens with Dynamic Memory allocation?
Answer: Dynamic -- run time. sizes and amounts can be set while
program running
Size and amounts are unknown before runtime, but can be changed
to fit the accurate size
◉ How do you create dynamic space?
Answer: You can create dynamic space with the "new" operator
Always use the TYPE after the word "new" (Ex: new INT)
◉ What does the new operator do past creating dynamic space?
, Answer: It returns the address of the allocated space, which can
(and should) use a pointer to store the address
◉ What can be dynamically allocated?
Answer: basic variables, objects, and arrays
Examples:
double* dptr = new double; int * list = new int[size]; Fraction* fptr1
= new Fraction; // uses default constructor Fraction* fptr2 = new
Fraction(1,2); // constructor with params Date* birthdayList = new
Date[20]; // array of Date objects
◉ Can you pass in a dynamically allocated object as a parameter in a
constructor?
Answer: True
◉ How do you deallocate dynamic memory?
Answer: use the "delete" operator
If you use a pointer, apply "delete" to the pointer, and it de-allocates
the target (Ex: delete pointer;)
If you use a dynamic array, use "delete [ ] pointername"