Given the following superclass: abstract class Shape { private int sides; abstract double area(); int sides() { return sides; } } Write the following Shape subclasses with the correct instance variables, constructors and area method: (Use Java) Shape sides area rectangle 4 length * width triangle 3 (height * base) / 2 square 4 side * side
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Given the following superclass:
abstract class Shape {
private int sides;
abstract double area();
int sides() { return sides; }
}
Write the following Shape subclasses with the correct instance variables, constructors and area method: (Use Java)
Shape |
sides |
area |
rectangle |
4 |
length * width |
triangle |
3 |
(height * base) / 2 |
square |
4 |
side * side |

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









