Page 1 of 1

The following lines of code include the Shape class and its Triangle child class. This code also includes a call to the

Posted: Fri Jul 08, 2022 6:45 am
by answerhappygod
The following lines of code include the Shape class and itsTriangle child class. This code also includes a call to the getAreamethod, which exists in the Triangle class but not the Shape class.How can that line be improved by making Shape an abstract classwith an abstract getArea method? Shape triangle = new Triangle();double area = ((Triangle) triangle).getArea();