Question: 1. Create two (2) classes named Car and TestCar. 2. In the Car class, initialize two (2) public static variables: MAKE (String, final) and

1. Create two (2) classes named Car and TestCar. 2. In the

1. Create two (2) classes named Car and TestCar. 2. In the Car class, initialize two (2) public static variables: MAKE (String, final) and numCars (int). Set their values to "Toyota" and 0, respectively. 3. Declare two (2) empty String instance variables named chassisNo and model. 4. Create a public constructor with a single parameter named model (String). This constructor should: Increment the value of numCars by one. Set the value of chassisNo based on the result of concatenating the String "ch" and the value of numCars. Syntax: chassis No = ch + numCars; Use the this keyword to set the instance variable model equal to the value of the parameter model. Display a message saying "Car manufactured". 5. Create two (2) pairs of getter and setter methods that will allow you to get and set the value of the two (2) instance variables: getModel() and setModel(), getChassis No() and setChassis No() 6. Add a public toString() method that will return and display the car's make, model, and chassis number in separate lines. 7. In the main method of the TestCar class, display the car's make and the initial number of manufactured cars by accessing them from the Cars class. Example: System.out.println("Manufacturer: " + Car.MAKE); 8. Instantiate two (2) Car objects assigning the values "Camry" and "Veloz", respectively. Example: Car car1 = new Car("Camry"); 9. Add two (2) statements to display the data of the two (2) Car objects. Example: System.out.println(car1); 10. Display the total number of cars manufactured by accessing the numCars method. Sample Output: //Initial values Manufacturer: Toyota Number of cars manufactured: 0 Car manufactured //After instantiating first Car object The car is manufactured by: Toyota The model type is Camry The chassis number is ch1 Car manufactured //After instantiating second Car object The car is manufactured by: Toyota The model type is Veloz The chassis number is ch2 //Total number of cars manufactured Number of cars manufactured: 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Carjava java public class Car public static final String MAKE Toyota public static int nu... View full answer

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!