206k views
0 votes
Write an interface called Playable, with a method void play(); Let this interface be placed in a package called music. Write a class called Veena which implements Playable interface. Let this class be placed in a package music.string Write a class called Saxophone which implements Playable interface. Let this class be placed in a package music.wind Write another class Test in a package called live. Then, a. Create an instance of Veena and call play() method b. Create an instance of Saxophone and call play() method c. Place the above instances in a variable of type playable and then call play

1 Answer

1 vote

Final answer:

The subject is Computer Science, and the grade is College. The question asks about creating an interface, implementing it in different classes, and calling methods on instances of those classes. The solution involves creating an interface called Playable, implementing it in Veena and Saxophone classes, and instantiating objects to call the play() method.

Step-by-step explanation:

The subject of this question is Computer Science and the grade is College.

The given question asks about creating an interface, implementing it in different classes, and calling methods on instances of those classes.

To solve this, we need to create an interface called Playable in the music package, with a void play() method. Then, we create a Veena class in the music.string package that implements the Playable interface, and a Saxophone class in the music.wind package that also implements the Playable interface. Finally, in the live package, we create a Test class where we can instantiate Veena and Saxophone objects and call their play() methods.

Keywords: Computer Science, College, interface, Playable, method, package, Veena, Saxophone, class, live, instantiate

User Gorill
by
9.1k points