Ask Question
17 September, 20:55

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?

+4
Answers (1)
  1. 18 September, 00:42
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers