Exam 15-16 Flashcards
Briefly explain what is meant by an object’s state. You may
provide an example to assist your answer
A state is an instance variable, the variable you use in the class
Briefly explain what is meant by an object’s behaviour. You may
provide an example to assist your answer
Behaviour is the Method/function, the method/function you use in the class.
If the object was a bike: Change gear, Cycle forward etc would be the behaviour.
A light can be switched on or off, and its brightness can be
adjusted, 0 - 100%. Suppose you were to design a Light class:
i) Give examples of two different fields for the light and their
data type.
“Brightness” where the datatype would be a integer.
“On/Off” where the datatype would be boolean.
A light can be switched on or off, and its brightness can be
adjusted, 0 - 100%. Suppose you were to design a Light class:
Identify a logical method that would change the state of
one of the fields.
Where On/Off = false: {
brightness = 0.