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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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

Post 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();
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply