Quiz 1 — C++ and the OOP Mindset¶
Ten questions on the build pipeline, values and references, and the four pillars. Attempt all of them closed-book, then mark yourself against the answers.
Concepts: preprocessing · compilation · linking · value vs reference · class vs object · the four pillars.
Q1. (MCQ) In which order do the build stages run?
- A. compilation → preprocessing → linking
- B. preprocessing → compilation → linking
- C. linking → compilation → preprocessing
- D. preprocessing → linking → compilation
Q2. (true/false) A missing semicolon is reported by the linker.
Q3. (MCQ) A function is declared and called but never defined. Which stage reports the problem?
- A. preprocessing
- B. compilation
- C. linking
- D. none — the program runs
Q4. (predict) Write the two lines this prints.
#include <iostream>
int main() {
int total = 7;
int half = total / 2;
double exact = total / 2.0;
std::cout << half << '\n';
std::cout << exact << '\n';
}
Q5. (short answer) Explain the difference between a class and an object in one sentence each.
Q6. (multiple-select) Which of these are pillars of object-oriented programming as this course uses the term? Select all that apply.
- A. Encapsulation
- B. Compilation
- C. Inheritance
- D. Polymorphism
- E. Abstraction
- F. Linking
Q7. (analysis) What is wrong with putting using namespace std; in a header file
that other files include?
Q8. (debug) This program will not compile. State the cause, then fix it with the smallest change.
Q9. (predict) State whether this compiles, and if it does, what it prints.
Q10. (design) For a student-record system, name two things you would model as types, and one thing you deliberately would not model as a type. Justify the exclusion in one sentence.
Scoring: mark yourself with the answers, then read the self-assessment guide.