Object-Oriented Programming (Cambridge (CIE) A Level Computer Science): Exam Questions

Exam code: 9618

14 mins2 questions
1a5 marks

A veterinary surgery wants to create a class for individual pets.
Some of the attributes required in the class are listed in the table.

Attribute

Data type

Description

PetID

STRING

unique ID assigned at registration

PetType

STRING

type of pet assigned at registration

OwnerTelephone

STRING

telephone number of owner assigned at registration

DateRegistered

DATE

date of registration

State one reason why the attributes would be declared as PRIVATE.

1b5 marks

Complete the class diagram for Pet, to include:

  • an attribute and data type for the name of the pet

  • an attribute and data type for the name of the owner

  • a method to create a Pet object and set attributes at the time of registration

  • a method to assign a pet ID

  • a method to assign the date of registration

  • a method to return the pet name

  • a method to return the owner’s telephone number.

Pet

PetID

: STRING

PetType

: STRING

OwnerTelephone

: STRING

DateRegistered

: DATE

......................................................................

: ...........................

: ...........................

..........................................................................................................................................................................................................................................................................................................................................

2a3 marks

Objects and classes form the basic structure of Object‑Oriented Programming (OOP).

Outline the structure of a class.

2b1 mark

Give three differences between an object and a class.