Week 2 - Object Concepts Flashcards
Based on unit 1, how would you describe an object?
Unit 1 describes an object as a self-contained unit of software that holds data and understands a set of messages that may cause it to perform behaviours such as changing state. Each object is able to communicate with other objects via messages.
Why is it better to reuse classes, the basis of OOP?
It is more economical leads to less mistakes and saves time.
In your own words, what does it mean to say that an instance of a class is intialised?
Instances of a class have attributes. It is usual for a newly created object to have its attributes initialised to some initial values.
What is a subclass and what is a superclass?
a subclass is a class that is derived from the protocls and attributes of another class which is then called the superclass.
What is inheritance?
It is the relationship between a subclass and its superclass, a subclass is said to inherit the attributes and the protocol from the superclass.
What criteria do you think the programmer has applied in deciding to create the cl;ass HoverFrog as a subclass of the class Frog?
The programmer required the instances of the class HoverFrog to have all the attributes of the class Frog, to understand all the messages that instances of the class Frog understand, and to behave in an identical way in response to most of these messages.
What is the message name in each of the following?
a) setColour(OUColour.YELLOW)
b) jump()
c) frog1.setColour(OUColour.BROWN)
d) hoverfrog2.green()
a) setColour()
b) jump()
c) setColour()
d) green()
In general, what is the difference between a message and a message name? What is the difference between a message and a message name when the message has no arguments?
A message name is the textual form of a message except that any arguments it takes are not shown. If a message takes no arguments the message and its name will be indistinguishable.
What is the message name in each of the following?
a) oldBicycle.remove(bell)
b) oldBicycle.install(bell, newBicycle)
a) remove()
b) install()
When the argument object and the receiver are collaborating, what is happening?
When one object(frog7, for example) is used as an argument in a message to another object (frog6, for example) we say that the argument object and the receiver are collaborating.
What is a getter message?
a getter message or an accessor message is a message that gets (returns) an attribute value, because it allows you to access information about an object.
What is a setter message?
a setter message or a mutator message, is a message that is intended to change the state of an object.
What, if anything, is returned as the message when the following message is sent to a Frog object that is brown?
a) getColour()
b) setColour(OUColour.RED)
a) OUColour.BROWN
b) no answer is returned.
In summary what is a class?
A class describes a group of objects that the programmer considers to be similar. Instances of the same class understand the same set of messages (their protocol), have the same attributes and behave in the same way in response to each message.
What is the receiver?
The receiver is the object to which a message will be sent.