Practice Exam Answer Key

Answer Key

Part I: Multiple-Choice Questions

  1. c) They provide reusable solutions to commonly occurring problems in software design.

  2. a) char *b[5];

  3. b) Singleton Pattern

  4. a) int *p; declares p as a pointer to an integer.

  5. a) It is used to allocate memory dynamically during program execution.

  6. c) A negative integer

  7. c) QMainWindow

  8. a) int (*funcPtr)(int, int);

  9. a) Deallocates memory previously allocated by new.

  10. a) Create an interface to allow incompatible interfaces to work together.

Part II: Code Output Prediction

  1. 10

  2. World

  3. 30

Part III: Coding Answer

#include <iostream>
using namespace std;

void allocateAndPrintArray(int n) {
int *arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = i + 1;
cout << arr[i] << " ";
}
cout << endl;
delete[] arr;
}

Once you complete the Practice Exam, upload your answers, and I will provide feedback on what you got right and wrong, explanations, and areas to focus on.

robot