Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help with a java program. this lab is over classes and objects. i have added the scope of work for this lab and is

need help with a java program. this lab is over classes and objects. i have added the scope of work for this lab and is in numerical order of steps we need to follow.

1. Define a Car class with three member field, String brand, String model, int year.

2. Define a constructor that takes arguments. For example, public Car(String brand, String model, int year);

3. In the constructor, use three assignment statements to assign three arguments values into three member fields as an initialization.

4. After the constructor, define three member methods (getBrand(), getModel(), getYear()) that return corresponding member field. For example, getBrand() function returns the value of variable Brand.

5. Note that Class Car doesnt have main method.

6. Define another class names as Lab6 in a different file. For example, public class Lab6 { }

7. In the main method of the class Lab6, declare a Car instance variable, instantiate, and initialize three member field using the constructor. For example, Car myCar = new Car(Toyota, Camry, 2017);

8. To verify the initialization, call all three member methods of class Car in the main method of class Lab6, and display the three values using the object and dot operator. For example, System.out.println(Brand: + myCar.getBrand);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions