Object Oriented Programming Flashcards
1
Q
Creating a Class & Constructor Method
A
class Pet private name public procedure new(john) name = John
2
Q
Creating Methods
A
public procedure setName(John) name = John endprocedure public function getName() return name end function
3
Q
Instantiation
A
To create an instance of an object the following format is usedobjectName = new className(parameters)
e.g.myDog = new Dog(“Fido”, “Scottish Terrier”)
4
Q
Inheritance
A
class Dog inherits Pet private breed public procedure new(givenName, givenBreed) super.new(givenName) breed=givenBreed endprocedure endclass
5
Q
Encapsulation
A
class BankAccount: def \_\_init\_\_(self): self._balance = 0 def deposit(self, amount): if amount > 0: self._balance += amount def get_balance(self): return self._balance