Question: 1) C reate an abstract class called Auto in Auto.java that contains the following data and methods: a) Private Class Data i) string brandName ii)

1) C reate an abstract class called Auto in Auto.java that contains the following data and methods: a) Private Class Data i) string brandName ii) double milesPerGallon iii) string color b) Public Class Methods i) Auto(string name, double mpg, string color) ii) string getBrandName() iii) void setBrandName(string name) iv) double getMilesPerGallon() v) void setMilesPerGallon(double mpg) vi) string getColor() vii) void setColor(string color) viii) abstract string printStats() 2) C reate a specialization class called Truck in Truck.java that extends the Auto class and contains the following data and methods: a) Private Class Data i) int horsePower b) Public Class Methods i) Truck(string name, doublempg, string color, int horsepower) ii) string printStats() - will return the information about the truck in string form. For example, "Truck Brand: GMC MPG: 5.0 Color: Silver HP: 600" 3) C reate a specialization class called Car in Car.java that extends the Auto class and contains the following data and methods: a) Private Class Data ii) integer numberOfDoors b) Public Class Methods i) Car(string name, doublempg, string color, int numDoors) ii) string printStats() - will return the information about the car in string form. For example, "Car Brand: Porsche MPG: 10.0 Color: Red Number of Doors: 4" Then create a test class called AutoTest in AutoTest.java that contains the following code in main(): ArrayList autoList = new ArrayList(); Car newCar = new Car("Corvette", 8.0, "Red", 2); Truck newTruck = new Truck("Toyota", 10.0, "Silver", 500); autoList.add(newCar); autoList.add(newTruck); for (Auto a : autoList) a.printStats(); When you run the test application, the output should be as follows: Car Brand: Corvette MPG: 8.0 Color: Red Number of Doors: 2 Truck Brand: Toyota MPG: 10.0 Color: Silver HP: 500 Also ensure that the following requirements are met:

  1. Java file is named correctly.
  2. Name, date and assignment information is included at the top of your Java code file as a comment.
  3. Java code is properly indented and readable.
  4. Code comments are present within each major section of code.

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 Programming Questions!