Exam 15-16 Flashcards

1
Q

Briefly explain what is meant by an object’s state. You may

provide an example to assist your answer

A

A state is an instance variable, the variable you use in the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Briefly explain what is meant by an object’s behaviour. You may
provide an example to assist your answer

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.

A

“Brightness” where the datatype would be a integer.

“On/Off” where the datatype would be boolean.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

A

Where On/Off = false: {

brightness = 0.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly