Intro to Java Programming Chapter 9 Questions and
Answers| Latest Update 100% Solved
What is the term used for a subclass that defines a method with the same name as a method in
its superclass, but with different parameter types?
A. implementing
B. overloading
C. inheriting
D. overriding ✔️✔️B
In Java, two methods can have the same name provided that what is true?
A. They cannot be defined in the same class.
B. They must be related to each other through inheritance.
C. They must differ in their parameter types.
D. One must be private and the other public. ✔️✔️C
Consider the following code snippet:
Vehicle aVehicle = new Auto();
, aVehicle.moveForward(200);
Assume that the Auto class inherits from the Vehicle class, and both classes have an
implementation of the moveForward method with the same set of parameters and the same
return type. The process for determining which class's moveForward method to execute is
called ____.
A. dynamic inheritance.
B. inheritance disambiguation.
C. dynamic method lookup.
D. inheritance hierarchy. ✔️✔️C
With a few exceptions, what access should instance variables of classes always have?
A. protected
B. public
C. final
D. private ✔️✔️D
Consider the following code snippet:
Vehicle aVehicle = new Auto(4,"gasoline");
String s = aVehicle.toString();
Answers| Latest Update 100% Solved
What is the term used for a subclass that defines a method with the same name as a method in
its superclass, but with different parameter types?
A. implementing
B. overloading
C. inheriting
D. overriding ✔️✔️B
In Java, two methods can have the same name provided that what is true?
A. They cannot be defined in the same class.
B. They must be related to each other through inheritance.
C. They must differ in their parameter types.
D. One must be private and the other public. ✔️✔️C
Consider the following code snippet:
Vehicle aVehicle = new Auto();
, aVehicle.moveForward(200);
Assume that the Auto class inherits from the Vehicle class, and both classes have an
implementation of the moveForward method with the same set of parameters and the same
return type. The process for determining which class's moveForward method to execute is
called ____.
A. dynamic inheritance.
B. inheritance disambiguation.
C. dynamic method lookup.
D. inheritance hierarchy. ✔️✔️C
With a few exceptions, what access should instance variables of classes always have?
A. protected
B. public
C. final
D. private ✔️✔️D
Consider the following code snippet:
Vehicle aVehicle = new Auto(4,"gasoline");
String s = aVehicle.toString();