Question: java solve a. Define a class named Rectangle. Add the following inside the class. 1. Declare 2 private instance variables length and width. 2. Add

 java solve a. Define a class named "Rectangle". Add the following

java solve

a. Define a class named "Rectangle". Add the following inside the class. 1. Declare 2 private instance variables length and width. 2. Add a parameterized constructor which will take 2 parameters. Inside the constructor initializes the attributes with the parameters passed to the constructor. 3. Add the following methods. a. public double getArea() - Inside the method, calculate the area of the rectangle and return the area. b. public void display() - inside the method, print the value of all three attributes. c. Add getter/setter method for the 2 attributes. b. Define a class named Box and make it the subclass of Rectangle (Q\#2.a.) class. Add an additional attribute height to this subclass. Add a parameterized constructor which will take 3 parameters for length, width and height. Inside the constructor, initialize the attributes in proper way. Add a method "public double getVolume0" and return the volume of the box from the method

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!