Object Oriented Languages (OCR A Level Computer Science)

Exam Questions

10 mins3 questions
13 marks

An object oriented system is implemented to organise further information about each worker’s attendance. Classes, objects, methods and attributes are used in this system.

State the meaning of each of the following terms:

  • Object

  • Method

  • Attribute

Did this page help you?

22 marks

Barney is writing a program to store data in a linked list. He is writing the initial program for a maximum of 10 data items.

Each node in the linked list has a data value and a pointer (to the next item).

A null pointer is stored with the value –1

Barney wants the nodes to be stored as objects using object-oriented programming. He designs the following class.

class: node

attributes: private
data : Real
private pointer : Integer

methods:

new (newData, newPointer)

getData()

getPointer()

setData(newData)

setPointer(newPointer)

The constructor assigns the parameters to the attributes to create an object

The class node, uses get methods and set methods.

Describe one difference between get methods and set methods.

Did this page help you?

35 marks

A business uses an array with the identifier wNames to store workers’ names. A variable with the identifier top is used to store the index of the last element to be added to the array, which is also the element which will next be removed.

wNames

0

1

2

3

4

5

6

Kirstie

Martyn

Louise

Alex

Anna

top

4

An object oriented system is implemented to organise further information about each worker’s attendance. Classes, objects, methods and attributes are used in this system.

Each worker has a name and an attendance figure which can be between 0 and 100.

Write a definition for a fully encapsulated customer class, providing both get and set methods for all attributes. You do not have to write code for the constructor method.

Did this page help you?