✅1.2.5 Object Oriented Programming Flashcards

(16 cards)

1
Q

What is a class?

A

A template for objects.

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

What is an object?

A

An instance of a class.

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

What is an attribute?

A

A value held by an object.

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

What is a method?

A

An action an object performs.

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

Describe one difference between get and set methods

A

A get method allows the attribute to be accessed. Whereas a set method allows the attribute to be changed (with parameters).

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

Describe what is meant by the term inheritance [3]

A

When a class takes on the methods (1) and attributes (1) of a parent class (1).

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

State the term that describes setSalary( ), setQualification( ) or setExtraFee( )

A

Method

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

Explain the meaning of the arrows in a class diagram

A

Shows inheritance

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

State the purpose of a constructor

A

Creates an instance of an object from a class

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

Explain 2 difference between passing a parameter by value and by reference

A
  1. By Value sends the actual value whereas by Reference sends a pointer to the value.
  2. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

6iii. State 2 advantages of using encapsulation.

A
  1. Reduces the chance of errors/inconsistences
  2. Ensures objects can only be changed in the way intended
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is encapsulation?

A

The practice of grouping attributes and methods within a class.

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

Explain 1 similarity and difference between a record and a class

A

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)

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

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]

A
  1. Classes, this a template. It will define what attributes and methods an object should have.
  2. A class can be used to declare the attributes and methods for the linked list. These will initialise the nodes and join them.
  3. 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.
  4. 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.
  5. Encapsulation, this protects attributes of an object by making them private so that they can’t be accessed or altered accidentally by other objects.
  6. 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.
  7. 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.
  8. OOP also allows programs to be easier to modify and maintain.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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]

A
  1. Queue has head pointer and tail pointer. [1]
  2. When an item is enqueued the tail pointer increments. [1]
  3. When an item is dequeued the head pointer increments. [1]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

DO OOP PSUEDOCODE QUESTIONS

A

https://reigatesixthformcollege-my.sharepoint.com/my?id=%2Fpersonal%2Fam233103%5Freigate%5Fac%5Fuk%2FDocuments%2FA%20LEVEL%20COMPUTER%20SCIENCE