Community resourceWorksheet
OCR H446 2.2.1 Classes, objects and constructors
Part 9 of 14 · H446 2.2.1 · Programming techniques
Object orientation enters H446 2.2.1 with a small set of ideas that must be kept apart: class, object, attribute, method and constructor. A loan and event-pass context is used here so students see one definition producing several objects that each hold independent state, expressed in Python and in OCR exam reference language.
Students will:
- distinguish a class definition from an object created from it
- identify what a constructor is responsible for alongside attributes and methods
- read a class diagram and implement the class it describes
- predict output that depends on two objects holding separate state
- instantiate several objects and call a method on one without affecting the others
Inside: 7 explanation cells, 1 multiple-choice question, 1 fill-in-the-blanks cell, 2 written answers and 2 Python tasks. 19 marks, about 25 to 35 minutes.
Series: H446 2.2.1 · Programming techniques, part 9 of 14.
Shared by Coding PathwayVerified teacher
- 13 cells
- About 30 minutes
- CC BY-SA 4.0
- Shared 31 Aug 2026
- Updated 3 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Classes, objects and constructors
A loan service creates many items from one class definition. Each object keeps independent state.
By the end, you will be able to
- distinguish class blueprint from object instance
- identify attributes, methods and constructor responsibilities
- instantiate multiple objects
- call methods and use returned values
Reactivate: functions, parameters and state-changing assignment.
Read a class diagram into code
The top compartment names the class, the middle lists attributes and their data types, and the final compartment lists the constructor and methods. The arrow on label() shows that it returns a String.
A class is the definition; instantiation creates an object. Mina's and Jay's objects use the same class definition but keep independent values. Calling a method selects the state belonging to the object before the dot.
One definition, separate state
The constructor runs once for each new object. camera.borrow() changes camera.available only; microphone is a different instance. Trace object state with one row per object rather than one row per class.
Instantiation pattern: variable = ClassName(arguments). Invocation pattern: variable.method(arguments). A method reference without parentheses does not perform the action.
OCR ERL bridge
OCR writes a constructor as a public procedure named new, and creates an instance with objectName = new ClassName(parameters).
class LoanItem
private item_name
public procedure new(givenName)
item_name = givenName
endprocedure
public function getName()
return item_name
endfunction
endclass
camera = new LoanItem("Camera")
print(camera.getName())
Python's __init__ has the same constructor responsibility but different notation.
Which statement correctly distinguishes a class from an object?
- AA class defines attributes and methods; an object is an instance with state.
- BA class is one instance; an object is its blueprint.
- CA class can have methods but an object cannot.
- DThey are unrelated.
class LoanItem:
def __init__(self, item_name):
self.item_name = item_name
self.available = True
def borrow(self):
self.available = False
def get_name(self):
return self.item_name
camera = LoanItem("Camera")
microphone = LoanItem("Microphone")
camera.borrow()
print(camera.available, microphone.available)Predict the two Boolean values printed and explain why the microphone's state does not change.
Refer to separate instances.
Students type their answer here.
Implement from the diagram
Use the EventPass class diagram above. The constructor stores holder and starts used as False. use() sets used True. label() returns holder followed by ': used' or ': ready'.
class EventPass:
passWrite Python statements that instantiate separate passes for 'Mina' and 'Jay', call use() on Mina's pass only, then print both returned labels.
Include parentheses for both constructions and every method call.
Students type their answer here.
Checkpoint
Complete the object-creation explanation from memory. There is no answer bank, and correctness is withheld until teacher review.
Review your understanding
Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify the resulting behaviour or consequence.