Question: Create an array of objects by completing the following parts: (5 marks) Declare a class Car and Declare three private instance variables (name, brand,
Create an array of objects by completing the following parts: (5 marks) Declare a class Car and Declare three private instance variables (name, brand, model) as (String, String, and int) respectively. Define the setter and getter methods for these variables. Define display method to print out a car's information (name, brand, model). In the main program: Create an array of the defined class Car with size 6. Create two objects from class Car and add them into the array. Set values (name, brand, model) for these two objects after adding them in the array. Show the two objects in the output using display method.
Step by Step Solution
There are 3 Steps involved in it
Java program public class Car Private instance variables private String name private String brand pr... View full answer
Get step-by-step solutions from verified subject matter experts
