User interface language: English | Español

Date May 2019 Marks available 1 Reference code 19M.2.SL.TZ0.10
Level SL Paper 2 Time zone no time zone
Command term State Question number 10 Adapted from N/A

Question

An international school organizes a regional swimming competition for students from 10 different schools. Each school will send a team of 5 to 15 swimmers.

Each swimmer can enter up to 5 events (such as the “50 m freestyle” or “100 m butterfly”).

Each event consists of one or more races. A race can be a qualifying heat, or a final. The final has the best 8 swimmers from all the qualifying heats in the event.

Each race has a maximum of 8 swimmers.

The UML diagrams for the classes Swimmer and Race are provided below.

In this scenario, Swimmer objects are aggregated in a Race object.

Define the term mutator method.

[1]
a.

State one additional instance variable of type boolean which could be added to the class Race as indicated above.

[1]
b.

With reference to both class UMLs provided above, distinguish between a class and an instantiation.

[3]
c.

Outline one advantage of using aggregation in this context.

[2]
d.i.

Outline one disadvantage of using aggregation in this context.

[2]
d.ii.

Construct code for the constructor of the class Swimmer that instantiates an object with parameters name and school. The event IDs should be set to “empty” and the times to 0.0

[4]
e.

Many swimmers in the event have names that cannot be represented using basic character sets such as ASCII.

Describe one feature of modern programming languages that allows the wide range of students’ names to be represented correctly.

[3]
f.

Markscheme

Award [1 max].
A method that allows/controls changes to a private (hidden) variable;

a.

Award [1 max].
boolean isFinals;

b.

Award [3 max].
The class Swimmer is the blueprint of a Swimmer object;
An instantiation is the actual object filled with data;
The class Race stores up to 8 different instantiated objects of the Swimmer class;

c.

Award [2 max].
Award [1] for identifying an advantage and [1] for an elaboration of the advantage up to [2 max].

Aggregation reduces dependencies;
and therefore reduces maintenance overhead;

d.i.

Award [2 max].
Award [1] for identifying a disadvantage and [1] for an elaboration of the disadvantage up to [2 max].

Aggregation of swimmers in a  object can cause issues with processing;
e.g. when searching for all heats that a particular swimmer participates in;

d.ii.

Award [4 max].
Award [1] for correct signature including parameters.
Award [1] for assigning name and school.
Award [1] for a (any) loop.
Award [1] for assigning empty to eventID[i].
Award [1] for assigning 0 (or 0.0) to time[i].

Example answer:

public Swimmer(String name, String school)
{
this.name = name;
this.school = school;
for(int i = 0, i < 5; i++)
{
eventID[i] = "empty";
time[i] = 0;
}
}
e.

Award [3 max].
Modern programming languages use Unicode to encode characters.
Which uses 16 bits / has about 64 000 characters.
As opposed to ASCII which uses 8 bits / has 256 characters.

f.

Examiners report

This was answered well. As this is an OOP course, some reference to objects, classes or encapsulation was expected which most students gave.

a.

Any sensible and non-trivial answer was accepted.

b.

Some candidates experienced difficulties in clearly distinguishing between the two terms. For the purpose of this course, a class is the template for objects which are created by instantiation.

c.

Candidates struggled to give a clear advantage (e.g. better organization) for aggregation.

d.i.

Candidates struggled to give a clear disadvantage (e.g. dependencies) for aggregation.

d.ii.

This was well-answered.

e.

It was clear from the various guesses that this topic hadn't been covered in some schools.

f.

Syllabus sections

Option D: Object-oriented programming » D.3 Program development
Show 45 related questions
Option D: Object-oriented programming

View options