Question: I need the Java Code for the following: Given two subclasses Bicycle and Automobile which are implemented as shown below, design a public Vehicle super

I need the Java Code for the following:

Given two subclasses Bicycle and Automobile which are implemented as shown below, design a public Vehicle super class which the subclasses will extend. Declare an abstract void method named "move()" which takes no parameters in the Vehicle class. Then define the Turnable interface (in the same file) which the subclasses implement; the interface includes an abstract void method named "turn()" which takes no parameters.

Use the attached "Vehicle_Stub.java" file (listed below)as a starter file and fill in the appropriate code where required. Save the file as "Vehicle.java" and then build and run it.

Don't declare the Turnable interface as public so it can be included in the Vehicle.java file.

Do not modify the main method provided in the Vehicle_Stub.java file.

Do not modify the Bicycle class or the Automobile class provided in the Vehicle_Stub.java file.

Be sure to add an ID header to the top of your file.

Expected Output:

Bicycle: use the handlebars. Bicycle: pedal. Automobile: use the steering wheel Automobile: step on the accelerator.

class Bicycle extends Vehicle implements Turnable { public void move() { System.out.println("Bicycle: pedal."); } public void turn() { System.out.println("Bicycle: use the handlebars."); } } class Automobile extends Vehicle implements Turnable { public void move() { System.out.println("Automobile: step on the accelerator."); } public void turn() { System.out.println("Automobile: use the steering wheel"); } }

Vehicle_Stub.java:

// class declaration goes here { public static void main(String args[]) { Bicycle b = new Bicycle(); Automobile a = new Automobile(); b.turn(); b.move(); a.turn(); a.move(); } // abstract method declaration goes here } // interface declaration goes here class Bicycle extends Vehicle implements Turnable { public void move() { System.out.println("Bicycle: pedal."); } public void turn() { System.out.println("Bicycle: use the handlebars."); } } class Automobile extends Vehicle implements Turnable { public void move() { System.out.println("Automobile: step on the accelerator."); } public void turn() { System.out.println("Automobile: use the steering wheel"); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!