Question: Write a class called Book in java that has the following instance variables: String title int pages along with the required accessor and toString methods.
Write a class called Book in java that has the following instance variables: String title int pages along with the required accessor and toString methods. Now write a subclass Textbook of this class Book that has the following additional instance variable String course Override the getTitle() method of the Book class by printing the title of the book and the course as well. Provide another accessor method getCourse(). Now in a main class, create an array of 10 books with some of them being textbooks. Using a for-loop print their titles, number of pages and if it is a textbook, then its course. Finally, count the number of textbooks, the number of books and print their quantities.
Please need it soon!!Thanks.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
