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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!