68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #59129 in Java | JSP | JSF for Peter

Question #59129
The UML for an Instantiable class called Vehicle is shown below:

Write an application program that uses an array to create three Vehicle objects with appropriate data. Add code to display the contents of the array.



+Vehicle(String, String)
Expert's answer
public class Main {
public static void main(String[] args) {
Vehicle array[] = new Vehicle[3];
array[0] = new Vehicle("BD51SMR", "Audio");
array[1] = new Vehicle("BD51SMR", "Ford");
array[2] = new Vehicle("UKPL8TE", "Mercedes");
for(int i = 0; i < array.length; i++){

public class Vehicle {
private String regNo;
private String carMake;

public Vehicle(){


public Vehicle(String regNo, String carMake){
this.regNo = regNo;
this.carMake = carMake;

public void setRegNo(String regNo){
this.regNo = regNo;

public void setCarMake(String carMake){
this.carMake = carMake;

public String getRegNo(){
return regNo;

public String getCarMake(){
return carMake;

public String toString(){
return regNo + " " + carMake;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions