Question :
Multiple Choice
Which of the following appropriately modeled using an : 2043793
Multiple Choice
-
Which of the following is appropriately modeled using an inheritance hierarchy?
- That an athlete is a person
- That a bird has a wing
- That an employee has a boss
- That an engine is part of a car
-
Which is the correct declaration for the class SportsCar?
- public class SportsCar extends Vehicle { . . . }
- public class Vehicle extends SportsCar { . . . }
- public class SportsCar extends Car { . . . }
- public class Car extends Vehicle { . . . }
-
If the instance variable declaration, private int _passengers; appears in class Car where would the statement _passengers = 5; be valid?
- in the definition of classes Vehicle and Car.
- in the definition of classes SportsCar and Car.
- in the definition of classes Vehicle, Car, and SportsCar
- only in the definition of class Car.
-
If the instance variable declaration, protected java.awt.Color _color; appears in class Vehicle where would the statement _color = java.awt.BLUE; be valid?
- only in the definition of class Vehicle.
- in the definition of classes Vehicle and Car but not in SportsCar.
- in the definition of classes Car and SportsCar but not in Vehicle.
- in the definition of classes Vehicle, Car, and SportsCar.
- Given that each of the three classes has a move method which accepts two integers as parameters, which move method would be invoked by the following statement in the SportsCar class definition.
super.move(5, 0);
- The move method of Vehicle.
- The move method of Car.
- The move method of SportsCar.
- The statement is ambiguous and will result in an error.
- Which class's constructor is invoked by the following statement located in the definition of the Car class.
super();
- The constructor with no parameters of the Vehicle class.
- The constructor with no parameters of the Car class.
- The constructor with no parameters of the SportsCar class.
- This statement does not invoke a constructor.
-
What is the purpose of defining an abstract method?
- It provides a default method implementation of that method if the subclasses don't define it.
- It forces all superclasses to define that method with the specified signature if they are not to be abstract classes.
- It forces all subclasses to define that method with the specified signature if they are not to be abstract classes.
- It allows the subclasses of the class from being instantiated.
-
The UML symbol which shows that an instance variable or method is protected is:
- –
- +
- #
- %
-
How do we make an object respond to clicking the mouse while it is on top of the object?
- We don't need to do anything special, it just responds.
- We need to make the object a subclass of the Mouse class.
- We need to make the object a superclass of the Mouse class.
- We need to write a mouseClicked method inside of the class of that object specifying what the object is to do when a mouse click occurs on the object.
-
The term pseudo-inheritance refers to:
- Subclasses inheriting the private properties of the superclass without "knowing it" or being able to access them directly.
- Superclasses inheriting the private properties of the subclass without "knowing it" or being able to access them directly.
- Subclasses inheriting the methods of the superclass.
- Superclasses inheriting the methods of the subclasses.
Solution
5 (1 Ratings )
Related Answers