Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Bike and EBike classes are implemented as shown by the code below. public class Bike { private String make; private int numGears; private double

The Bike and EBike classes are implemented as shown by the code below.

public class Bike { private String make; private int numGears; private double tirePressure; public Bike(String m, int g, double t) { make = m; numGears = g; tirePressure = t; } public void pumpTire() { tirePressure += 5.0; } } public class EBike extends Bike { private int batteryLevel; public EBike(String m, int g, double t, int b) { super(m, g, t); batteryLevel = b; } public void chargeBattery() { batteryLevel++; } }

A new private int variable, currentGear is added to the Bike class. Which of the following describes the best implementation of a changeGear method which would allow the value of currentGear to be changed by instances of the Bike and EBike classes?

A public changeGear method is added to the Bike class only.

A public changeGear method is added to the EBike class only.

A private changeGear method is added to the EBike class only.

A private changeGear method is added to the Bike class only.

A private changeGear method is added to both theBike and EBike classes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions