Object Oriented Programming Flashcards

1
Q

Creating a Class & Constructor Method

A
class Pet
    private name
		
		
	public procedure new(john)
		name = John
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Creating Methods

A
public procedure setName(John)
       name = John
endprocedure

public function getName()
        return name
end function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Instantiation

A

To create an instance of an object the following format is used
objectName = new className(parameters)
e.g.
myDog = new Dog(“Fido”, “Scottish Terrier”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Inheritance

A
class Dog inherits Pet
 private breed
 public procedure new(givenName, givenBreed)
 super.new(givenName)
 breed=givenBreed
 endprocedure
endclass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly