3. Create a clas Rectangle having member variables a,b, and area to store the values of length of two sides and the area respectively. Write methods to initialize the sides and putArea()- calculate and print the area of the rectangle. Create a class Triangle that inherits from class Rectangle. Reuse the member variables a and b to store its two sides. Override the putArea() method of class Rectangle to compute and print the area of the triangle. Create a Demo classto test the above classes.
View All Comments
| View Tutorial