Date | November 2018 | Marks available | 1 | Reference code | 18N.2.SL.TZ0.11 |
Level | SL | Paper | 2 | Time zone | no time zone |
Command term | State | Question number | 11 | Adapted from | N/A |
Question
Outline the use of data-hiding as a security feature in OOP.
The Arrival
object has two methods named compareWith
.
Outline why calling the compareWith
method does not cause a conflict.
State the name of this OOP property.
Markscheme
Award up to [2 max].
Award [1] for stating encapsulation as an OOP property.
Award [1] for an elaboration.
Example answer:
Encapsulation allows to make instance variables (and methods) of a class private to that class;
So that the main program / other classes can't accidentally access / change the data in an object;
Award up to [2 max].
The two methods have different parameters;
allowing the compiler to choose the correct one.
Polymorphism