Question: Write Java program where it contains the following: A class to define a kind of objects in real - world ( i . e .

Write Java program where it contains the following:
A class to define a kind of objects in real-world (i.e. cars, chairs);
A main class (main program) to create an array of objects with 4 instances your class.
Assign different properties (attributes) to each element via the setters. And then get the
properties via the getters and output the properties to the console.
Basic Requirement:
You need to submit 2.java files: one for the class of a kind of real-world objects
and one for the main class;
Write your classes under a package named assign1;
Use the name convention: Assign1_pXXXXXXX as the class name of your main
No inner classes (e.g. a class declared in the main class);
For the class of real-world objects:
Define 2 properties of the class;
Explicitly define 1 constructor to initialize the properties with initial
values;
All the properties must be initialized with a value within the constructor.
You must not just let Java assign the default value to them;
Define a getter and a setter per each property, and 1 method for some
other behavior to the class (e.g. calculate the area of a circle by using the
radius). I.e. the total number of your class is 2+2+1=5.
Example Output:
A Rectangle class has 2 properties: width and height.
2 getters, 2 setters and 1 methods - getArea() are defined.
Output result:
 Write Java program where it contains the following: A class to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!