The following lines of code include the Shape class and its Triangle child class. This code also includes a call to the
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
The following lines of code include the Shape class and its Triangle child class. This code also includes a call to the
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();