Week 15 — Quiz (auto-graded) · Intro to Object-Oriented Programming
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective tested: Objective 8 — classes, objects, attributes, methods, init, and self.
Points: 10 (1 each) · Assignment group: Quizzes (10% of grade) · Due: end of Module 15.
Human-readable quiz with its vetted answer key. Import-ready Classic QTI in
F-quiz-week-15-qti.xml(parses with 10 items, one correct per single-answer item). Execution gate: PASS — every keyed output/result was produced by running the code.
Questions, key, and feedback
Q1 (MC). What is the relationship between a CLASS and an OBJECT?
- A. they are the same thing
- B. a class is a blueprint; an object is a specific thing built from it ✅
- C. an object is a blueprint; a class is built from it
- D. a class is a kind of loop
Feedback: A class is the blueprint; an object (instance) is a specific thing built from it. One class, many objects.
Q2 (MC). What special method runs automatically when you create an object, setting up its starting attributes?
- A. start()
- B. __init__ ✅
- C. main()
- D. self()
Feedback: __init__ is the constructor — Python calls it for you when you create the object.
Q3 (MC). What does this print?
class Dog:
def __init__(self, name):
self.name = name
def speak(self):
return self.name + ' says Woof!'
print(Dog('Rex').speak())
- A.
Woof! - B.
Rex says Woof!✅ - C.
Dog says Woof! - D.
says Woof! Rex
Feedback:__init__stored'Rex'asself.name;speak()returns it plus' says Woof!'. (Run-verified.)
Q4 (MC). What does this print?
class Rectangle:
def __init__(self, w, h):
self.width = w
self.height = h
def area(self):
return self.width * self.height
print(Rectangle(3, 4).area())
- A.
7 - B.
12✅ - C.
34 - D.
6
Feedback:area()returns width × height = 3 × 4 = 12. (Run-verified.)
Q5 (MC). What does this print?
class BankAccount:
def __init__(self, balance):
self.balance = balance
def deposit(self, amount):
self.balance = self.balance + amount
a = BankAccount(100)
a.deposit(50)
print(a.balance)
- A.
100 - B.
50 - C.
150✅ - D.
5000
Feedback:deposit(50)added 50 to the balance attribute: 100 + 50 = 150. The object remembers its state. (Run-verified.)
Q6 (Multiple answer — select all that apply). Which statements about classes and objects are true?
- A. __init__ runs automatically when you create an object ✅
- B. self refers to the object a method is called on ✅
- C. All objects of a class share one copy of each attribute
- D. You store data on an object with self.attribute = value ✅
- E. A class is a blueprint for creating objects ✅
Feedback: A, B, D, E are true. C is false — each object has its own attributes.
Q7 (Matching). Match each term to its meaning.
| Term | Meaning |
|---|---|
| Class | A blueprint for creating objects |
| Object (instance) | A specific thing built from a class |
| Attribute | A piece of an object's data (self.x) |
| Method | A function that belongs to an object |
Feedback: Class = blueprint; object = a thing built from it; attribute = its data; method = its behavior.
Q8 (True / False). "Two objects created from the same class each have their own copy of the attributes, so changing one does not change the other."
- True ✅
- False
Feedback: True. Each instance carries its own state. (Run-verified: two Counters incremented differently gave 2 and 1.)
Q9 (MC). In a method definition like def speak(self):, what is self?
- A. the name of the class
- B. the object the method is called on ✅
- C. a number
- D. a built-in function
Feedback: self is the object the method is acting on; Python passes it automatically when you write d.speak().
Q10 (MC). This class crashes with AttributeError when speak() runs. What is the fix?
class Cat:
def __init__(self, name):
name = name
def speak(self):
return self.name + ' says Meow'
- A. Rename the class to
cat(lowercase) - B. Change
name = nametoself.name = namein__init__✅ - C. Remove the
speakmethod - D. Add a semicolon after
name = name
Feedback:name = namenever stored the value on the object, soself.namedoesn't exist. Useself.name = name. (Run-verified: withself., it printsMilo says Meow.)
Answer key (quick reference)
| Q | Answer | Q | Answer |
|---|---|---|---|
| 1 | B (blueprint vs thing) | 6 | A, B, D, E |
| 2 | B (init) | 7 | Class→blueprint / Object→built from it / Attribute→data / Method→behavior |
| 3 | B (Rex says Woof!) | 8 | True |
| 4 | B (12) | 9 | B (the object) |
| 5 | C (150) | 10 | B (self.name = name) |
Quality gate (self-checked): each single-answer item has exactly one correct option; the multiple-answer item keys are exact; the matching item pairs one-to-one. Execution gate: PASS — every printed output (Q3 Rex says Woof!; Q4 12; Q5 150) and the missing-self AttributeError (Q8, Q10) were produced by running the code in Python.
Canvas placement block
canvas_object = Quizzes::Quiz
title = "Week 15 Quiz — Intro to Object-Oriented Programming"
assignment_group = "Quizzes"
points_possible = 10
grading_type = points
due_offset_days = 6
published = true
shuffle_answers = true
ai_permitted = false
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
F-quiz-week-15-qti.xml) ships inside the course's .imscc package — it lands in the Canvas gradebook on import.~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com