Inheritance
Rather than starting with a high-level description, I think it'll be best if we jump right into a problem.
To get us started, I've created a basic Java program, which we can access from the given code files. In this program, we declare two Java classes: a Book class and a Poem class. Both the Book and Poem classes store a number of attributes; for example, Book can have a title, an author, a publisher, and a genre. It takes all these attributes as constructor input and provides a single public method; we can use the Print method in our main program to print out information about any books we create.
The Poem method does something very similar. It has a couple of attributes and a Print method, and we set its attributes through ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access