Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions