1.2.4 (e) & (d) Types of Programming Language & Modes of Addressing - Object Oriented Programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/33

flashcard set

Earn XP

Description and Tags

COMPLETE

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

What is a class?

a template defining methods & attributes used to construct a set of objects

2
New cards

What are objects?

  • program building blocks

  • self-contained instances of classes based on real world entities which contai attributes & methods

3
New cards

What is a method?

a subroutine that forms the actions an object can carry out

4
New cards

What is an attribute?

a data value stored in a variable associated with an object

5
New cards

What is the purpose of a constructor?

creates an instance of an object from a class

6
New cards

What does OOP attempt to do?

capture/group information,data & code into structured items known as objects

7
New cards

What are the three sections of a class?

  • class name

  • attributes

  • methods

8
New cards

What are two advantages of OOP?

  • allows for code reusability

  • easier to modify + maintain programs

9
New cards

What is instantiation?

process of creating an object from a class template

10
New cards

What is the constructor used in psuedocode?

new

11
New cards

What is the constructor used in python code?

__init__

12
New cards

Why is the word “private“ used to define attributes in psuedocode?

this means that no one can access and change the attribute (only can do this through get and set)

13
New cards

What does a get method allow us to do?

allows attribute to be accessed/returned

14
New cards

What does a set method allow us to do?

allows attributes to be changed (w/ parameters)

15
New cards

In psuedocode what do you have to write at the end of every class?

endclass

16
New cards

What happens to the parameters when the object is instantiated?

the constructor method takes values of parameters and sets it to local attributes

17
New cards

What is inheritance used for?

  • quickly & easily reuse code from the superclass

  • extend attributes & methods without affecting the original code

18
New cards

Define inheritance

when a class takes on methods & attributes of a parent class

19
New cards

What may the inheriting class do?

  • overide some methods/attributes

  • may have additional methods/attributes

20
New cards

What is the keyword used to override and get something from the parent class?

super

21
New cards

What is a super class/parent class?

the original template that is inherited from

22
New cards

What are the classes that inherit from the superclass/parentclass called?

subclass/childclass

23
New cards

What is encapsulation?

  • process of hiding data by keeping an object’s attributes private

    • values can only be directly accessed & changed via public methods (defined for the class and not from outside the class)

24
New cards

What does encapsulation maintain?

data integrity

25
New cards

What does encapsulation prevent?

  • indiscriminate, unexpected changes to attributes(could have unforeseen consequences)

26
New cards

What is polymorphism?

objects of different types can be treated in the same way

27
New cards

What does polymorphism allow?

allows same method to be applied to objects of different classes

28
New cards

What is an example of polymorphism using an array?

an array with objects of different classes having the same method to all of them

29
New cards

What is an advantage of polymorphism?

reduced volume of code produced - same code able to handle different objects

30
New cards

What is an example of polymorphism using a class diagram?

all of the classes may have the same method name “makeSound()” however they may all output different things depending on the class they’re in

31
New cards

What are the 4 modes of addressing?

  • immediate

  • direct

  • indirect

  • indexed

32
New cards

What are advanatages of OOP?

  • code reusability

    • classes used in other programs

    • inheritances extends upon existing classes

  • easy maintainability

    • classes can be modified/extended

    • debugging easier as encapsulation limits how attributes changed

  • more secure code

    • encapsulation - attributes can only be accessed/changed via public methods

  • better coding for team

    • classes can be distributed between team members

33
New cards

How could OOP be applied to a linked list?

  • class declaring attributes + methods for linked lists - intialise the nodes & join them

  • each time new node = create new object from class

  • subclasses can take on attributes + emthods from base class & also override + add

  • encapsulation used by using get & set to ensure nodes are only changed in intended way

34
New cards

How could OOP be applied to a video game?

  • call on classes per type of player/enemy object

  • one enemy/player class may generate many enemy/player objects w/ diff value attributes

  • special types of player/enemy objects can inherit from parent classes + allow for additional attributes

  • polymorphism allows attributes/methods of player/enemy objects to behave differently from normal if required