Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image

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

Step: 1

Carjava java public class Car public static final String MAKE Toyota public static int nu... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Programming questions

Question

How have psychologists and others confounded sex and gender?

Answered: 1 week ago