Books can come in various formats, like paper books, audio books, ebooks, etc. Create a generic class Book that has as common attributes the title, the year of publication, and the author. The constructor of this class should instantiate all three attributes. Override the toString method of class Book that returns a string that contains the values of its attributes. Create a subclass PrintBook that extends Book with attributes Publisher and ISBN. Create another subclass AudioBook which has the book’s size (in MB), its play length and the playback artist’s name as attributes. Both PrintBook and AudioBook classes override the toString method inherited from Book. Write a Java application to demonstrate the usage of this hierarchy.
Books can come in various formats, like paper books, audio books, ebooks, etc. Create a generic class
Book that has as common attributes the title, the year of publication, and the author. The constructor of this
class should instantiate all three attributes. Override the toString method of class Book that returns a string
that contains the values of its attributes. Create a subclass PrintBook that extends Book with attributes
Publisher and ISBN. Create another subclass AudioBook which has the book’s size (in MB), its play
length and the playback artist’s name as attributes. Both PrintBook and AudioBook classes override the
toString method inherited from Book. Write a Java application to demonstrate the usage of this hierarchy.
Step by step
Solved in 2 steps with 5 images