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?

Respuesta :

Answer:

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.

ACCESS MORE