Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following method declarations overrides this method? double calcula

ID: 3873609 • Letter: W

Question

Which of the following method declarations overrides this method?

double calculateMilesPerGallon(double speed){...}

a.

double calculateMilesPerGallon(int speed){...}

b.

double calculateMilesPerGallon(double s){...}

c.

double calculateMilesPerGallon(double speed, int r){...}

d.

double calculate(double speed){...}

Hierarchy 11-1

Vehicle

MotorVehicle WaterCraft

Automobile        Motorcycle Sailboat          Canoe

(Refer to inheritance hierarchy 11-1.) If the constructor that follows is called, it calls a constructor from which class?

public Sailboat(int sails) {

    super();

    this.sails = sails;

}

a.

Sailboat

b.

Canoe

c.

WaterCraft

d.

Vehicle

(Refer to inheritance hierarchy 11-1.) If the MotorVehicle class contains a protected method named getEngineType, what other class or classes can access this method?

a.

Vehicle, Automobile, and Motorcycle

d.

Vehicle

b.

Vehicle and WaterCraft

e.

no other classes can access it

c.

Automobile and Motorcycle

If the Point class doesn’t override the equals method in the Object class, what will the following code do?

Point pointOne = new Point(3, 4);

Point pointTwo = new Point(3, 4);

System.out.println(pointOne.equals(pointTwo));

a.

Cause a compile-time error since the equals method doesn’t exist in the Point class

b.

Cause a compile-time error since the equals method can’t accept a Point object

c.

Print “true” to the console

d.

Print “false” to the console

a.

double calculateMilesPerGallon(int speed){...}

b.

double calculateMilesPerGallon(double s){...}

c.

double calculateMilesPerGallon(double speed, int r){...}

d.

double calculate(double speed){...}

Explanation / Answer

Which of the following method declarations overrides this method?
double calculateMilesPerGallon(double speed){...}

Ans: b.double calculateMilesPerGallon(double s){...}

While overrding only referral arguments will change.

If the constructor that follows is called, it calls a constructor from which class?
public Sailboat(int sails) {
super();
this.sails = sails;
}

Ans: c. WaterCraft

If the MotorVehicle class contains a protected method named getEngineType, what other class or classes can access this method?
Ans: d.Vehicle
Explanation: If any Variables or methods that are declared as protected can only be accessed by the subclasses in other class or package.


If the Point class doesn’t override the equals method in the Object class, what will the following code do?
Point pointOne = new Point(3, 4);
Point pointTwo = new Point(3, 4);
System.out.println(pointOne.equals(pointTwo));

Ans: c. Print “false” to the console

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote