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
Get step-by-step solutions from verified subject matter experts
