Question: Write a program to create a class named Vehicle with attributes price, mileage and fuel and an initializer to initialize all the instance variables. Vehicle
Write a program to create a class named Vehicle with attributes price, mileage and fuel and an initializer to initialize all the instance variables. Vehicle class must have a method getFuel() which returns the fuel and a method addFuel() to add the fuel. Create a subclass of Vehicle named Car with attribute car_name. Override the addFuel() method. Also override the getFuel() method in Car class to display the name of the Car and return the available fuel.
Step by Step Solution
3.35 Rating (161 Votes )
There are 3 Steps involved in it
The program is written in Java language and contains a Main class to execute cla... View full answer
Get step-by-step solutions from verified subject matter experts
