Question :
Multiple Choice
Use the UML diagram for the Trees hierarchy which : 2043803
Multiple Choice
Use the UML diagram for the Trees hierarchy which is attached to answer questions 1 through 5.
-
If we have a variable whose declared type is Tree and actual type is Maple, what messages can it perform?
- Only grow.
- All of the methods for class Maple, and for class Deciduous, and for class Tree.
- Only the methods for class Maple
- Only the methods for class Tree and for class Maple, but not the methods for class Deciduous.
-
If we have an object whose declared type is Tree and actual type is Oak that is passed the message dropLeaves, which dropLeaves method will it perform?
- The dropLeaves method declared in class Deciduous
- The dropLeaves method declared in class Oak
- The dropLeaves method declared in class Maple
- None of the above answers are correct because sending a dropLeaves message to this object is not valid.
-
If we have an object whose declared type is Conifer and actual type is Pine that is passed the message dropCones, which dropCones method will it perform?
- The dropCones method declared in class Conifer
- The dropCones method declared in class Pine
- The dropCones method declared in class Spruce
- None of the above answers are correct because sending a dropCones message to this object is not valid.
-
If we have an object whose declared type is Deciduous and actual type is Maple, which grow method will it perform?
- The one which is defined in class Tree
- The one which is defined in class Deciduous
- The one which is defined in class Maple
- None of the above answers are correct because sending a grow message to this object is not valid.
-
If we have an object whose declared type is Deciduous and actual type is Oak, which is passed the message changeColor(java.awt.Color.ORANGE), which changeColor method will it use?
- The one which is defined in class Tree
- The one which is defined in class Deciduous
- The one which is defined in class Oak
- None of the above answers are correct because sending a changeColor message with actual parameter java.awt.Color.ORANGE is not valid for this object.
-
If a method has a parameter of type Colorable that is passed an object of type WagonBody, which of the following messages are valid for it to receive?
- Only the methods defined in Wagon
- Only the methods defined in Wagon Body
- Only the methods defined in both Rectangle and WagonBody
- Only the methods defined in Colorable
-
If an object is declared type Draggable and actual type Wheel the message mouseDragged will be bound to which of the following mouseDragged methods?
- The one defined in Ellipse
- The one defined in Wheel
- The one defined in Wagon
- None of the above will be bound to the object by the message mouseDragged.
-
If an object is declared type Colorable and actual type WagonBody the message setColor will be bound to which of the following setColor methods?
- The one defined in Wagon
- The one defined in Colorable
- The one defined in Rectangle
- None of the above answers are correct because sending a setColor message to this object is not valid.
-
If an object is declared type Draggable and actual type Wagon the message move will be bound to which of the following move methods?
- The one defined in Draggable
- The one defined in WagonBody
- The one defined in Wheel
- The one defined in Wagon
-
If a variable object1 is declared type Draggable which of the following instantiations is not valid?
- object1 = new Draggable();
- object1 = new Wagon();
- object1 = new Wheel();
- object1 = new WagonBody();
Solution
5 (1 Ratings )
Related Answers