Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following code represents a Bicycle object with the gear, speed properties, and different constructors to create a Bicycle object public class Bicycle { protected

The following code represents a Bicycle object with the gear, speed properties, and different constructors to create a Bicycle object
public class Bicycle {
protected int gear;
protected int speed;
//Copy (Clone) Constructor
public Bicycle (Bicycle ob){
gear = ob.gear;
speed = ob. speed;
}
//Constructor used when all the attributes are specified
public Bicycle (int gear, int speed){
this.speed = speed;
this.gear = gear;
}
//Constructor used when no attributes are specified (Default)
public Bicycle (){
gear=0;
speed=0;
}
}
Create a class called MountainBike that inherits from Bicycle class and has a seatHeight of type double property. Create Constructors for this class similar to the ones for the Bicycle class taking into consideration the seatHieght property:
A Copy (clone) constructor
A Constructor when speed, gear, and the seatHeight are specified
A Default Constructor that sets the seatHeight to 10 and other attributes to their default values.
A Constructor for creating a MountainBike with a given seatHeight. Other attributes to their default values.

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

5. What are the two key assumptions of self-expansion theory?

Answered: 1 week ago