Books can come in various formats, like paper books, audio books, ebooks, etc. Create a generic class
Question:
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 Answer:
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates