Ask Question
19 August, 21:31

2. You have classes to represent different shapes (see below). You realize you can benefit from inheritance and polymorphism by creating a superclass for all shapes. a. Create such a superclass. b. Did you choose an abstract class or an interface for your answer to part a? c. Why did you make this choice?

+5
Answers (1)
  1. 19 August, 21:44
    0
    The description for the given question is described in the explanation section below.

    Explanation:

    a ...

    interface Shape

    {

    public double getArea (); / / creating a function

    public double getPerimeter (); / / creating a function

    }

    b and c ...

    I preferred Interface although abstract classes are being used when children's classes associate certain aspect methods and variables and because all classes represent a certain method throughout the specific solution, not instance variables, it would be easier to construct an interface. Almost all of the period interfaces are favored because they have multiple inheritance capabilities.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “2. You have classes to represent different shapes (see below). You realize you can benefit from inheritance and polymorphism by creating a ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers