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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started