Abstract Class vs Interface
The following classes are modifications of those in Example 13.4. Here, Playable is an abstract class rather than an interface,
public abstract class Playable { public abstract void play(); }and CD, DVD, and MP3 each extends, rather than implements, Playable.
public class CD extends Playable { // methods for CD } public class DVD extends Playable { // methods for DVD } public class MP3 extends Playable { // methods for MP3 }a. Explain the advantages of designing Playable as an interface rather than as an abstract class.
b. Describe a different example where an interface is clearly preferable to an abstract class.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.