Question: Apply the Object Oriented principles in answering the below question. a.Create a class Rectangle having two attributes length and width of type int . Keep

Apply the Object Oriented principles in answering the below question.

a.Create a class Rectangle having two attributes length and width of type int. Keep length as

private and width as protected.

b.Provide the parameterised constructors to Rectangle class.

c.The Rectangle class has a method area that returns int value.

d.Derive the class ThreeDRectangle by adding a protected int attribute height. The ThreeDRectangle overrides the method area of the Rectangle class.

e.ThreeDRectangle has a method volume that returns int value.

[ Hint: area = length * width; volume= length * width*height]

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 Programming Questions!