Question: java: WRITING PART 1. Consider the following definition of class MyClass class MyClass { private String A; private char B; private int C; private double
java:
WRITING PART
1. Consider the following definition of class MyClass
class MyClass
{
private String A;
private char B;
private int C;
private double D;
a.Create a default constructor assigning , , 0, and 0.0 to the class variables. Hints: Read default constructor in your textbook.
b.Create the second constructor that has two parameters assigned to A and B.
c. Create the third constructor that has four parameters assigned to A, B, C, and D.
d. Create get methods for the class variables.
e. Create set methods for the class variables.
f. Create an object named X. In object X, initialize A to Table and B to T. Use the most appropriate constructor to create this object.
g. Create the second object named Y. In object Y, initialize A to Chair, B to k, C to 100, and D to 5.99. Use the most appropriate constructor to create this object.
h. Create the third object named Z. In object Z, initialize A to , B to , C to 0, and D to 0.0. Use the most appropriate constructor to create this object.
i. Display the value of A in object X.
j. Display the value of C in object Z.
k. Assign ? as the new value of B in object Y.
l. Display the value of B in object Y.
m. Assign 7 as the new value of C in object X.
n. Assign 3.12 as the new value of D in object Z.
o. Display the value of C in object X.
p. Display the value of D in object Z.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
