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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started