Question: 1 . Consider the code snippet below. This code models a simple hierarchy of Vehicle and Car classes. Vehicle is a general class containing color
Consider the code snippet below. This code models a simple hierarchy of Vehicle and Car classes. Vehicle is a general class containing color and speed as member fields and methods to accelerate and brake. Car is a specific type of Vehicle, and it inherits the properties and methods of Vehicle. It also contains an additional member field brand.Your task is to complete the missing portions of code in the snippet.Please note that missing codes in ABCD and E do not have to be limited to one line. MarksExpected Output of the java program is as follows:Vehicle Color: RedVehicle Speed: Accelerating... New Speed: Braking... New Speed: Car Color: BlueCar Speed: Car Brand: ToyotaAccelerating... New Speed: Braking... New Speed: Java code:class Vehicle private String color; private int speed; public VehicleString color this.color color; this.speed ; public void accelerateMISSING CODE A System.out.printlnAccelerating New Speed: speed; public void brakeMISSING CODE B System.out.printlnBraking New Speed: speed; public String getColorreturn color; public int getSpeedreturn speed; class Car extends MISSING CODE C private String brand; public CarString color, String brandMISSING CODE D this.brand brand; public String getBrand return brand; public class Main public static void mainString args Vehicle vehicle new VehicleRed; System.out.printlnVehicle Color: MISSING CODE E; System.out.printlnVehicle Speed: vehicle.getSpeed; vehicle.accelerate; vehicle.brake; Car car new CarBlue "Toyota"; System.out.printlnCar Color: car.getColor; System.out.printlnCar Speed: car.getSpeed; System.out.printlnCar Brand: car.getBrand; car.accelerate; car.brake;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
