✅1.2.5 Object Oriented Programming Flashcards
(16 cards)
What is a class?
A template for objects.
What is an object?
An instance of a class.
What is an attribute?
A value held by an object.
What is a method?
An action an object performs.
Describe one difference between get and set methods
A get method allows the attribute to be accessed. Whereas a set method allows the attribute to be changed (with parameters).
Describe what is meant by the term inheritance [3]
When a class takes on the methods (1) and attributes (1) of a parent class (1).
State the term that describes setSalary( ), setQualification( ) or setExtraFee( )
Method
Explain the meaning of the arrows in a class diagram
Shows inheritance
State the purpose of a constructor
Creates an instance of an object from a class
Explain 2 difference between passing a parameter by value and by reference
- By Value sends the actual value whereas by Reference sends a pointer to the value.
- With by value, if changes are made then only the local copy is amended. Whereas by reference If changed the original is also changed when the subroutine ends.
6iii. State 2 advantages of using encapsulation.
- Reduces the chance of errors/inconsistences
- Ensures objects can only be changed in the way intended
What is encapsulation?
The practice of grouping attributes and methods within a class.
Explain 1 similarity and difference between a record and a class
Similarities:
1. Both store data of different types. Which can be accessed by their names
Differences:
1. A record is a data structure whereas a class is a template for making data structures (objects)
Barney would like his linked list to be part of a base program that is saved in a library. This means that it can be reused and changed by other programs. Discuss the benefits of using different object-oriented techniques that Barney could use to achieve this. [12]
- Classes, this a template. It will define what attributes and methods an object should have.
- A class can be used to declare the attributes and methods for the linked list. These will initialise the nodes and join them.
- Objects, when you create an instance of a class. Each object that is instantiated from the same class will share the same attributes and methods.
- Objects can then be used be used to instantiate the class each time a new linked list is needed. Each can be given a different identifier by the other programs.
- Encapsulation, this protects attributes of an object by making them private so that they can’t be accessed or altered accidentally by other objects.
- Encapsulation can be used by using set and get methods to ensure that the nodes in the linked list are changed in a way that is intended.
- Use of OPP techniques will allow for code reusability. His linked list can be saved as library and then reused many times leading to less code.
- OOP also allows programs to be easier to modify and maintain.
A program is amended to include the use of several queue data structures. Describe how an array can be used to implement a queue data structure. [3]
- Queue has head pointer and tail pointer. [1]
- When an item is enqueued the tail pointer increments. [1]
- When an item is dequeued the head pointer increments. [1]
DO OOP PSUEDOCODE QUESTIONS
https://reigatesixthformcollege-my.sharepoint.com/my?id=%2Fpersonal%2Fam233103%5Freigate%5Fac%5Fuk%2FDocuments%2FA%20LEVEL%20COMPUTER%20SCIENCE