Back to marketplace

OOP

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

Class

Back (Answer)

Defines a type of object using OOP. each object is an instance of the class

#2
Front (Question)

Attribute

Back (Answer)

a value within an OOP class

#3
Front (Question)

OOP Method

Back (Answer)

procedures or functions written within an OOP class

#4
Front (Question)

OOP Object

Back (Answer)

an independent entity OOP defines the attributes of an object OOP defines the methods that can be applied to the object many instances of the object can be declared

#5
Front (Question)

Constructor in OOP

Back (Answer)

takes place immediatelly after defining the class . -sets attributes - gives them starting values - provides parameters

#6
Front (Question)

write a constructor in python (with two attributes called att1 and att2, set to the parameters p1 and p2)

Back (Answer)

def __init__(self, p1, p2): self.att1=p1 self.att2=p2

#7
Front (Question)

advantages of OOP

Back (Answer)

easier to read code less work in long run better control over the process fewer erros good for team work

#8
Front (Question)

disadvantages of OOP

Back (Answer)

needs careful planning more work at the start objects must be similar

#9
Front (Question)

class Car(): def__init__(self, p1, p2): self.colour = p1 self.make = p2 self.speed = 0 create an instance of the car class called mycar that is a pink miata

Back (Answer)

mycar = Car(“Pink”,”Miata”)

#10
Front (Question)

imagine this method is written within an OOP class: def gofaster(self): self.speed = self.speed + 10 in the main program, write a line of code to use this method on mycar

Back (Answer)

mycar.gofaster()

#11
Front (Question)

rewrite this constructor in psuedocode: class Car(): def__init__(self, p1, p2): self.colour = p1 self.make = p2 self.speed = 0

Back (Answer)

class Car procedure new(p1, p2) colour = p1 make = p2 speed = 0 end procedure end class

#12
Front (Question)

inheritance

Back (Answer)

one class can “inherit” all the features of another class.

#13
Front (Question)

show the first line of a class definition of a class Y that inherits class X

Back (Answer)

Class Y inherits X

#14
Front (Question)

what do we call the class that inherits / the class it inherits from

Back (Answer)

super class and sub class or parent class and child class

#15
Front (Question)

encapsulation

Back (Answer)

using private methods and attribites in OOP • they cannot be altered directly, only accessed via “get” and “set” methods.

#16
Front (Question)

get and set methods

Back (Answer)

if an attribute is private we cant show or change it in the main program, so get and set methods are used instead

#17
Front (Question)

write a get method for the attribute colour in pseudocode

Back (Answer)

public procedure getcolour() return colour end procedure

#18
Front (Question)

write a set method for the attribute colour in psuedocode, using p1 as the parameter

Back (Answer)

public procedure setcolour(p1) colour = p1 end procedure

#19
Front (Question)

What is inheritance in OOP

Back (Answer)

A sub class can inherit attributes and methods from an existing super - class. The subclass is then defined by making alterations or additions to the super- class.

#20
Front (Question)

(psuedocode) here is a superclass. class Employee public procedure new(surname, jobtitle): surname = surname jobtitle = jobtitle end procedure endclass now write a subclass for manager with their name and title, explaining which line inherits what.

Back (Answer)

-class manager inherits Employee - public procedure new (thisname, thistitle) - super.new( thisname, thistitle) • end procedure -endclass the first line inherits all the methods of the superclass the third line inherits all attributes from the super class

#21
Front (Question)

here is the pseudocode for a sub- class . class manager inherits Employee public procedure new (thisname, thistitle) super.new( thisname, thistitle) end procedure endclass add a line to this constructor, that will add a new attribute called “manages” and set the variable to 0 .

Back (Answer)

class manager inherits Employee public procedure new (thisname, thistitle) super.new( thisname, thistitle) manages = 0 end procedure endclass

#22
Front (Question)

(psuedocode) here is a class defenition. Now write it in python class Employee public procedure new(surname, jobtitle): surname = surname jobtitle = jobtitle end procedure endclass

Back (Answer)

Class Employee(): def __init__(self, surname, jobtitle) self.surname = surname self.jobtitle = jobtitile

#23
Front (Question)

here is a superclass written in python. Class Employee(): def __init__(self, surname, jobtitle) self.surname = surname self.jobtitle = jobtitile now write a subclass for manager with their name and title

Back (Answer)

class Manager (Employee): def __init__(self, thisname, thistitle) super(). __init__ (thisname, thistitle) end procedure endclass

#24
Front (Question)

in python, write the opening line for a class constructor called car. then, write the opening line for a class constructor called car which inherits the class vehicle

Back (Answer)

class Car(): class Car(Vehicle):