Programming with Objects

OOP Classes

Part 1 of the Paper 4 OOP chapter — the blueprint idea (classes vs objects), the constructor and attributes, methods with self, and creating instances in a main program. The four skills every Paper 4 OOP question is built from, plus the full OOP vocabulary glossary.

20.1 Introduction to OOP

You already organise the world into things. A phone is a thing: it has data (a model, a battery level) and it does jobs (ring, take a photo). A student is a thing too: they have a name and a grade, and they do things like move up a year. Object-Oriented Programming (OOP) lets you write programs the same way — by building “things” called objects that bundle their data and their actions together in one place.

Before OOP, you stored a student's data in separate variables and wrote loose functions that hoped to be passed the right ones. OOP fixes that by keeping each object's data and the actions that work on it locked together. This makes programs easier to read, reuse and maintain — and it is exactly what Paper 4 asks you to design and write.

By the end of this page you will be able to explain the difference between a class and an object, write a class with a constructor and attributes, add methods that change an object's data, and create objects and use them in a main program — the four skills every Paper 4 OOP question is built from.

What this page covers
  • The core OOP terminology and how to build and use a simple class with public attributes and methods.
  • Encapsulation, private attributes, getters and setters are covered in OOP Part 2.
  • Containment (aggregation) is on the OOP Containment page.
  • Inheritance and polymorphism are in OOP Part 4.
TermMeaning
ClassA blueprint (template) that describes what data an object will hold and what it can do. Like an architect’s plan for a house.
ObjectA real “thing” built from a class, with its own actual values. Like one finished house built from the plan.
InstanceAnother word for an object. Each object is an instance of its class — one house is an instance of the house plan.
Attribute (property)A piece of data stored inside an object, e.g. a student’s name or grade.
MethodAn action an object can perform, written as a function inside the class, e.g. promote().
ConstructorA special method that runs automatically when an object is created and sets up its starting attributes. In Python it is __init__.
selfInside a class, self means “this particular object”. It lets a method reach the object’s own attributes.
InstantiationThe act of creating an object from a class. When you write x = Student(...) you are instantiating.

20.1.1 Classes and Objects — the Blueprint Idea

Why are we doing this?
  • Before you write any code, you must be crystal clear on one idea, because every other OOP topic depends on it.
  • A class is a plan, and an object is a thing made from that plan.
  • Mix these two up and your exam answers — and your code — fall apart.
Exam tip:
  • Examiner focus: “Outline the structure of a class” appeared in 9618/32 O/N 2024 Q10(a) [3].
  • “Give three differences between an object and a class” appeared in the same question Q10(b) [3].
  • Plain theory marks are sitting here for anyone who can describe a class and separate it from an object.

Think about a printed registration form. The blank form is the plan — it has spaces for a name and a grade, but it holds no real student. When you photocopy it and write “Musarrat, Grade 11” on one copy and “Aymaan, Grade 12” on another, each filled-in copy is a real thing with its own values.

In OOP, the blank form is the class. Each filled-in copy is an object (also called an instance). You define the class once, then you can create as many objects from it as you like, and each object keeps its own separate data.

ClassObject
A template / blueprint — written once.A specific thing created from the class — you can create many.
Defines what attributes and methods exist.Holds actual values for those attributes.
No memory is set aside for data when the class is defined.Memory is allocated when the object is created.
Key rule A class is defined once; many objects (instances) can be created from it, and each object stores its own separate data.
Task — Worked Example — Identify class, attributes, method [4 marks]
Identify (AO2). A clinic at Uttara keeps a record for each patient. From the description below, identify the class, two suitable attributes, and one suitable method. "Each patient has a name and an age. The clinic needs to be able to book the patient in for an appointment." [4]
Hint:
  • Step 1 — find the “thing”: the repeated noun the record is about.
  • Step 2 — find the data it has (“has a name and an age”).
  • Step 3 — find what it does (“book the patient in”).
Your Turn — Your Turn — Identify class, attributes, method [4 marks]
Identify (AO2). A gym in Dhaka keeps a record for each member. "Each member has a name and a number of visits this month. The gym needs to be able to record a new visit." Identify the class, two attributes, and one method. [4]
Hint:
  • The “thing” is the repeated noun; “has” points to attributes, the action points to a method.
Task — Worked Example 20.1.1B — Attribute or method?
Is each item below an attribute or a method of a Car class? colour, startEngine, speed.
Hint:
  • If it is data the car has → attribute. If it is something the car does → method.
Your Turn — Your Turn 20.1.1B — Attribute or method?
Is each item an attribute or a method of a BankAccount class? balance, deposit, accountNumber.
Hint:
  • “has” vs “does”.
Exam tip:
  • For “differences between an object and a class”, give separate, distinct points — examiners will not reward the same idea twice.
  • Strong point: a class is a definition/template while an object is an instance with actual values.
  • Strong point: a class is written once while many objects can be created.
  • Strong point: memory is allocated when the object is created, not when the class is defined.

20.1.2 Building a Class — the Constructor and Attributes

Why are we doing this?
  • An empty class is useless until each object can be given its starting data.
  • The constructor is the method that does this: it runs the moment an object is created and copies the values you pass in into the object's own attributes.
  • Get the constructor right and the rest of the class falls into place.
Exam tip:
  • Examiner focus: Writing a class and its constructor is core Paper 4 code.
  • In 9618/42 O/N 2021 Q2(a) [5] candidates had to declare a class and write its constructor that takes parameters and sets them to attributes — and in Python, declare each attribute with a comment.
  • The structure of the class earns the marks, not clever tricks.

A class definition starts with the keyword class followed by the class name (use PascalCase: Student, BankAccount). Everything that belongs to the class is indented underneath it.

Inside the class, the constructor in Python is always named __init__ (two underscores either side). Its first parameter is always self — that word stands for “the object being built right now”. The remaining parameters are the values you hand over when creating the object. Inside the constructor you copy each parameter into an attribute written as self.attributeName.

class Student:
    def __init__(self, name, grade):
        self.name  = name      # attribute: stores the student's name
        self.grade = grade     # attribute: stores the year group

Here is the same idea in Cambridge pseudocode. The pseudocode constructor is a procedure named NEW, and attributes are declared explicitly:

CLASS Student
    PUBLIC Name : STRING
    PUBLIC Grade : INTEGER
    PUBLIC PROCEDURE NEW(GivenName : STRING, GivenGrade : INTEGER)
        Name  <- GivenName
        Grade <- GivenGrade
    ENDPROCEDURE
ENDCLASS
Key rule
  • In Python the constructor is __init__(self, ...); in Cambridge pseudocode it is a procedure named NEW.
  • Its job is to copy the parameters into the object's attributes using self. (Python) or direct assignment (pseudocode).
Task — Worked Example — Book class with constructor [4 marks]
Write program code (AO3). Write a class Book with a constructor that takes a title and an author and stores them as public attributes. Declare each attribute with a comment. [4]
Hint:
  • Step 1 — class header: class Book: and indent everything inside.
  • Step 2 — constructor with parameters: def __init__(self, title, author): — self first, then the two values.
  • Step 3 — copy into attributes: assign each parameter to a self. attribute and comment it.
Your Turn — Your Turn — Movie class with constructor [4 marks]
Write program code (AO3). Write a class Movie with a constructor that takes a name and a director and stores them as public attributes. Declare each attribute with a comment. [4]
Hint:
  • Mirror the Book example exactly; only the class name, parameters and attribute names change.
Task — Worked Example 20.1.2B — Wallet with a fixed starting value
Write a constructor for a Wallet class that takes an owner and starts balance at 0.
Hint:
  • Not every attribute needs a parameter — balance sensibly starts at 0.
Your Turn — Your Turn 20.1.2B — Ticket with a fixed starting value
Write a constructor for a Ticket class that takes a holderName and starts status as "Pending".
Hint:
  • One parameter, one fixed starting value.
Exam tip:
  • If you write in Python, the syllabus requires you to declare each attribute with a comment (e.g. # attribute: book title) so the examiner can see your design.
  • Pseudocode declares them with DECLARE/type lines instead.
  • Forgetting the comments in a Python answer can cost you the design mark.

20.1.3 Adding Methods — Giving Objects Behaviour

Why are we doing this?
  • Attributes are only half of an object — they are the data.
  • Methods are the actions that read or change that data.
  • Bundling the data and the actions together in one class is the whole point of OOP: the object that holds the grade is the same object that knows how to change the grade.
Exam tip:
  • Examiner focus: Writing methods that update a property (a setter-style action) and return a property (a getter-style action) is examined directly.
  • See 9618/42 O/N 2021 Q2(b) [3], where candidates wrote the get methods of a class.
  • Methods that change attribute values are equally common.

A method is just a function written inside the class. Like the constructor, its first parameter is self, because the method needs to know which object's attributes it should work on. To reach an attribute from inside a method, you write self.attributeName.

Here is a method that promotes a student by adding 1 to their grade. Notice it reads the current grade with self.grade, adds one, and stores the new value back into the same attribute:

class Student:
    def __init__(self, name, grade):
        self.name  = name
        self.grade = grade

    def promote(self):
        self.grade = self.grade + 1   # change this object's grade

    def display(self):
        print("Name:",  self.name)
        print("Grade:", self.grade)

The pseudocode equivalent uses PUBLIC PROCEDURE for an action that does something, and PUBLIC FUNCTION ... RETURNS for a method that hands a value back:

PUBLIC PROCEDURE Promote()
    Grade <- Grade + 1
ENDPROCEDURE

PUBLIC FUNCTION GetGrade() RETURNS INTEGER
    RETURN Grade
ENDFUNCTION
Key rule
  • Every method's first parameter is self.
  • Use self.attribute inside the method to read or change that object's own data.
  • A method that returns a value is a function; a method that just acts is a procedure.
Task — Worked Example — BankAccount.deposit(amount) [3 marks]
Write program code (AO3). A BankAccount class already has an attribute balance. Write a method deposit(amount) that adds the amount to the balance. [3]
Hint:
  • Step 1 — method header with self: def deposit(self, amount): — self first, then the value to add.
  • Step 2 — change the attribute: read self.balance, add amount, store it back.
Your Turn — Your Turn — FitnessTracker.updateSteps(steps) [3 marks]
Write program code (AO3). A FitnessTracker class has an attribute totalSteps. Write a method updateSteps(steps) that adds steps to totalSteps. [3]
Hint:
  • Same shape as deposit: header with self, then update the attribute.
Task — Worked Example 20.1.3B — getName (getter)
Write a method getName that returns the object's name attribute.
Hint:
  • A method that hands a value back uses return — this is a “getter”.
Your Turn — Your Turn 20.1.3B — shipOrder (setter)
Write a method shipOrder that sets the object's status attribute to "Shipped".
Hint:
  • This one changes an attribute, so no return.
Exam tip:
  • The most common slip is leaving out self — either in the method header or before the attribute name.
  • Without self., Python treats it as a brand-new local variable and the object's real attribute never changes.
  • Examiners watch for self on the parameter list and on every attribute reference.

20.1.4 Creating and Using Objects (Instances)

Why are we doing this?
  • A class on its own does nothing — it is just a plan sitting on a shelf.
  • The program only comes alive when you create objects from the class and call their methods.
  • In Paper 4 the marks for the main program are awarded specifically for creating the object and using its methods, so this final step is where your design actually earns marks.
Exam tip:
  • Examiner focus: Paper 4 mark schemes consistently require the main program to create the object and then call the methods on it.
  • Code that defines a perfect class but never instantiates it loses the application marks — the examiner needs to see the object in use.

To create an object, write the class name followed by brackets, passing in the values the constructor expects. The constructor runs automatically. This act is called instantiation, and the object you get back is an instance of the class. Once you have the object you reach its attributes with object.attribute and call its methods with object.method().

musarrat = Student("Musarrat", 11)   # create (instantiate) an object
musarrat.display()                   # call a method
musarrat.promote()                   # change the object's data
musarrat.display()                   # show the updated data

# Output:
# Name: Musarrat
# Grade: 11
# Name: Musarrat
# Grade: 12

The pseudocode equivalent creates the object with NEW and calls methods with the same dot notation:

Musarrat <- NEW Student("Musarrat", 11)
Musarrat.Display()
Musarrat.Promote()
Musarrat.Display()
Key rule
  • Creating an object is instantiation; the object is an instance of the class.
  • Each instance keeps its own attribute values, so calling aymaan.promote() changes only Aymaan's grade — not anyone else's.
Task — Worked Example — Create and use a Student [3 marks]
Write program code (AO3). Using the Student class, write a main program that creates a student "Tarnima" in grade 11, displays her details, promotes her, then displays them again. [3]
Hint:
  • Step 1 — instantiate: tarnima = Student("Tarnima", 11).
  • Step 2 — use the object: call display(), then promote(), then display() again.
Your Turn — Your Turn — Create and use a BankAccount [3 marks]
Write program code (AO3). Using a BankAccount class with attribute balance and method deposit(amount), write a main program that creates an account for "Naib" with balance 500, deposits 250, then prints the balance. [3]
Hint:
  • Instantiate first, then call deposit, then print naib.balance.
Task — Worked Example 20.1.4B — Two instances, separate data
Create two Student objects, mehrin (grade 11) and mohar (grade 12), and promote only mehrin. What grade is each now?
Hint:
  • Each instance has its own data — promoting one does not affect the other.
Your Turn — Your Turn 20.1.4B — Two Wallets, separate data
Create two Wallet objects, nazifa and nawal (both start at balance 0), and add 100 to nawal only. What is each balance?
Hint:
  • Separate instances keep separate data.
Exam tip:
  • A complete Paper 4 OOP answer almost always needs three parts: the class definition, then object creation, then method calls.
  • If a question says “test your class”, that is your cue to add the main program — leaving it out forfeits easy application marks.

20.1B Class-Building Drills

Each drill shows one class solved on the left, then a matching task of the same type on the right. Work through the left, cover it, then attempt the right before tapping Show answer. These are skill drills — no marks attached.

Task — Drill 1 — Worked Example: Book.describe()
Class Book with attributes title, author and a method describe() that prints "The book … is written by …". Create an object and call it.
Hint:
  • Constructor stores title and author; describe() prints them with print("The book", self.title, "is written by", self.author).
Your Turn — Drill 1 — Your Turn: Movie.details()
Class Movie with attributes name, director and a method details() that prints "The movie … is directed by …". Create an object and call it.
Hint:
  • Mirror Book; only names change.
Task — Drill 2 — Worked Example: read a Book's attributes directly
Create a Book object and print its title and author directly, without a method.
Hint:
  • Use object.attribute to read a value from outside the class.
Your Turn — Drill 2 — Your Turn: Car (brand, year)
Write a class Car with attributes brand and year. Create an object, then access its attributes directly and print them.
Hint:
  • No method needed; print car1.brand and car1.year.
Task — Drill 3 — Worked Example: BankAccount.deposit()
Class BankAccount with accountHolder and balance. Method deposit(amount) increases the balance. Test it.
Hint:
  • deposit reads self.balance, adds amount, stores it back.
Your Turn — Drill 3 — Your Turn: Wallet.addMoney()
Class Wallet with owner and a balance starting at 0. Method addMoney(amount) increases the balance by a given amount. Test it.
Hint:
  • Same shape as deposit; balance starts at 0 with no parameter.
Task — Drill 4 — Worked Example: Workshop.addParticipant()
Class Workshop with workshopName, trainer, and participants (starts at 0). Method addParticipant() increases participants by one.
Hint:
  • Increment with + 1; the method takes no extra parameter.
Your Turn — Drill 4 — Your Turn: Classroom.addStudent()
Class Classroom with subject, teacher, and students (starts at 0). Method addStudent() increases students by one.
Hint:
  • Increment with + 1; the method takes no extra parameter.
Task — Drill 5 — Worked Example: Book.borrowBook()
Class Book with title, author, and isBorrowed (starts False). Method borrowBook() sets it to True if it is currently False.
Hint:
  • Toggle a Boolean: check if not self.isBorrowed, then set self.isBorrowed = True.
Your Turn — Drill 5 — Your Turn: Movie.rentMovie()
Class Movie with title, director, and isAvailable (starts True). Method rentMovie() sets it to False if it is currently True.
Hint:
  • Mirror borrowBook, but the Boolean starts the other way round.
Task — Drill 6 — Worked Example: Order.shipOrder() + displayOrderInfo()
Class Order with orderID, customerName, and orderStatus (starts "Pending"). Method shipOrder() sets the status to "Shipped"; displayOrderInfo() prints all details. Display, ship, display again.
Hint:
  • One method changes the status string, one prints everything.
Your Turn — Drill 6 — Your Turn: Ticket.confirmTicket() + displayTicketInfo()
Class Ticket with ticketID, holderName, and status (starts "Unconfirmed"). Method confirmTicket() sets the status to "Confirmed"; displayTicketInfo() prints all details.
Hint:
  • Same pattern as Order: one method changes the status, one prints everything.
Task — Drill 7 — Worked Example: FitnessTracker.updateSteps()
Class FitnessTracker with userName, totalSteps (starts 0), dailyGoal. Method updateSteps(steps) adds steps; displayProgress() prints the details.
Hint:
  • Accumulate a total with self.totalSteps = self.totalSteps + steps, then display all attributes.
Your Turn — Drill 7 — Your Turn: StudyTracker.logHours()
Class StudyTracker with studentName, totalHours (starts 0), dailyTarget. Method logHours(hours) adds hours; displayStudyProgress() prints the details.
Hint:
  • This is the exact twin of FitnessTracker; only the words change.
Spot the bug — promote never changes the grade A student wrote this promote method, but the grade never changes. Predict what is wrong, then reveal the answer.
def promote(self):
    grade = grade + 1   # the grade never updates — why?
Task — Show the fix
The line uses a plain variable grade instead of the object's attribute self.grade. Reveal the fix.
Hint:
  • Python treats grade as a brand-new local variable, so the object's real attribute is never read or changed (and the line raises an error).
  • Fix: put self. on both sides.

20.1C Full Exam-Style Question

Paper 4 · OOP · ~12 marks
  • The canteen at a school runs a loyalty scheme written using object-oriented programming.
  • Each member has a card that stores the holder's name and a number of reward points.

(a) State two differences between an object and a class. [2]

(b)(i) Write program code to declare a class LoyaltyCard with a constructor that takes the holder's name as a parameter and sets the reward points to 0. Use public attributes and, if writing in Python, declare each attribute with a comment. [4]

(b)(ii) Write a method addPoints(amount) that increases the reward points by the given amount. [3]

(c) Write a main program that creates a loyalty card for “Tarnima”, adds 50 points, then outputs the holder's name and points. [3]

Lab Task — Show full solution & mark scheme
Reveal the model solution and mark scheme for parts (a)–(c).
Hint:
  • (a) two distinct differences (template vs instance; defined once vs many created; memory on creation).
  • (b)(i) class header, constructor with self + holderName, self.holderName set, self.points = 0 (with comments).
  • (b)(ii) method header with self + amount, read self.points, store updated value back.
  • (c) create object with "Tarnima", call addPoints(50), output name and points.

20.1.5 The Full OOP Vocabulary

Why are we doing this?
  • The very first OOP objective in the syllabus is pure terminology, and examiners reward you for defining and matching these words precisely — even before you can write the code for all of them.
  • Treat this table as your one-stop glossary for the whole OOP chapter.
Exam tip:
  • Examiner focus: Defining encapsulation, getter and setter was worth 3 marks in 9618/32 O/N 2022 Q10(a).
  • Matching OOP terms to their descriptions was worth 4 marks in 9618/32 M/J 2023 Q4.
  • Knowing the vocabulary cold is free marks.
TermPlain-English meaningWhere you use it
ClassA blueprint that defines what attributes and methods an object will have.This page
Object / InstanceA specific thing built from a class, holding its own real values.This page
Attribute (property)A piece of data stored inside an object.This page
MethodAn action — a function — written inside a class.This page
ConstructorA special method that sets up a new object automatically (NEW in pseudocode, __init__ in Python).This page
EncapsulationBundling data and the methods that work on it inside one class, and hiding the data from outside code.OOP Part 2
GetterA method that returns the value of an attribute.OOP Part 2
SetterA method that updates the value of an attribute.OOP Part 2
Public / PrivateAccess modifiers. Public members are reachable anywhere; private members are usable only inside the class (PRIVATE in pseudocode, a __ prefix in Python).OOP Part 2
InheritanceA child (sub) class reuses the attributes and methods of a parent (super) class (INHERITS in pseudocode, class Child(Parent) in Python).OOP Part 4
PolymorphismThe same method name behaves differently depending on the object’s class (method overriding).OOP Part 4
Containment (aggregation)An object holds other objects as its attributes — e.g. an Invoice that contains several Order objects.OOP Containment
Key rule
  • Public members can be accessed from anywhere; private members can be used only inside their own class — written as PRIVATE in pseudocode or with a __ prefix in Python.
  • Hiding attributes as private and reaching them only through getters and setters is what encapsulation means in practice (you build exactly this in Part 2).

Key Points Summary

OOP bundles data (attributes) and the actions that work on it (methods) together inside one class — the object that holds the grade is the same object that knows how to change it.
A class is a blueprint/template defined once; an object (instance) is a specific thing built from it, holding its own real values. One class → many objects.
Memory is allocated when an object is created (instantiation), not when the class is defined.
In Python the constructor is always __init__(self, ...); in Cambridge pseudocode it is a procedure named NEW(...).
The first parameter of every method (including the constructor) is self — it means "this particular object" and lets the method reach the object's own attributes.
Inside a method, use self.attributeName to read or change that object's own data. Without self., Python treats it as a local variable and the attribute never changes.
A method that returns a value is a function (PUBLIC FUNCTION ... RETURNS in pseudocode); a method that just acts is a procedure (PUBLIC PROCEDURE).
A getter returns an attribute's value (return self.name); a setter updates an attribute (self.status = "Shipped").
In Python OOP answers, declare each attribute with a comment (e.g. # attribute: book title) so the examiner can see your design — forgetting comments can cost the design mark.
Class names use PascalCase: Student, BankAccount, LoyaltyCard.
Create an object with obj = ClassName(...) (Python) or obj <- NEW ClassName(...) (pseudocode). The constructor runs automatically.
Reach an attribute from outside with object.attribute; call a method with object.method().
Each instance keeps its own separate attribute values — calling mehrin.promote() changes only Mehrin's grade, not Mohar's.
A complete Paper 4 OOP answer needs three parts: the class definition, then object creation, then method calls. If a question says "test your class", add the main program.
Encapsulation bundles data and methods in one class and hides the data from outside code (private attributes + getters/setters) — covered in Part 2.
Inheritance lets a child class reuse a parent class (Part 4); polymorphism means the same method name behaves differently; containment means an object holds other objects.
Public members are reachable anywhere; private members (PRIVATE in pseudocode, __ prefix in Python) are usable only inside the class.

20.1D Practice Tasks

Fifteen exam-style tasks. Click Hint for bullet-point guidance, then Help to reveal a worked Python solution.

1Practice Task — Identify class, attributes, method [4 marks]
A library keeps a record for each book. "Each book has a title and an ISBN. The library needs to be able to borrow the book out." Identify the class, two attributes, and one method.
2Practice Task — Differences between a class and an object [3 marks]
State three differences between a class and an object.
3Practice Task — Attribute or method? [3 marks]
For a Song class, classify each as attribute or method: title, play, duration, artist, pause.
4Practice Task — Write a class with constructor [4 marks]
Write a class Product with a constructor that takes a name and a price and stores them as public attributes. Declare each attribute with a comment.
5Practice Task — Constructor with a fixed starting value [3 marks]
Write a constructor for a Counter class that takes a label and starts count at 0.
6Practice Task — Write a method that updates an attribute [3 marks]
A ScoreBoard class has an attribute score. Write a method addPoints(points) that adds points to score.
7Practice Task — Write a getter method [2 marks]
Write a method getPrice that returns the object's price attribute.
8Practice Task — Write a setter method [2 marks]
Write a method setDiscount that sets the object's discount attribute to a value passed in.
9Practice Task — Increment a counter by one [3 marks]
A Clicker class has a clicks attribute starting at 0. Write a method click() that increases clicks by one.
10Practice Task — Toggle a Boolean attribute [4 marks]
A Light class has isOn starting False. Write a method toggle() that flips isOn to the opposite value.
11Practice Task — Create and use an object [3 marks]
Using a Player class with a method showInfo(), write a main program that creates a player "Tarnima" at level 1 and shows their info.
12Practice Task — Two instances, separate data [3 marks]
Create two Lamp objects (both isOn = False), turn one on with toggle(). What is each isOn afterwards?
13Practice Task — Spot the bug [2 marks]
This method does not change the balance. Why? `def withdraw(self, amount): balance = balance - amount`
14Practice Task — Full class + method + main program [8 marks]
Write a class Countdown with a starting value (starts at a number passed in). Method tick() decreases the value by 1. Write a main program that creates a countdown from 5, ticks twice, and prints the value.
15Practice Task — Define OOP terms [4 marks]
Define: (a) encapsulation, (b) getter, (c) setter, (d) instantiation.

Question Bank

Answer all questions, then press Submit Quiz to see your score.

0/12 answered

Question 1Multiple Choice

A class is best described as:

Question 2Multiple Choice

In Python, the constructor method is named:

Question 3True / False

Every method's first parameter is self.

Question 4Multiple Choice

What does self.attributeName do inside a method?

Question 5Multiple Choice

How do you instantiate an object in Python?

Question 6Multiple Choice

A method that returns the value of an attribute is a:

Question 7Multiple Choice

Which is a difference between a class and an object?

Question 8True / False

In a Python OOP answer, you must declare each attribute with a comment.

Question 9Multiple Choice

What is encapsulation?

Question 10Multiple Choice

In pseudocode, the constructor is a procedure named:

Question 11Multiple Choice

What is inheritance?

Question 12Multiple Choice

A complete Paper 4 OOP answer needs:

Answer all 12 questions to enable submission.