Unit 9: OOP – Inheritance
Overview:
Inheritance is a foundational OOP concept in Java. You have the ability to use all of the data and services from an existing class and write a class that is a more specific version of that class. This is called extending a class. E.g. You have a class called Person that represents all of the data and services that all
Persons would have and do. Maybe your program needs a more specific type of person like a Teacher or a Student.
You would not want to write all of the code again that creates a Person, you already did all of that work! You could write a Student class that extends the Person class.
Student would have all of the things that a Person would have and then the added functionality of a Student. We will look at several examples of inheritance hierarchies and build on to one of them in the BOTS
project.
In this chapter you will learn about:
• Superclass and subclass
• Protected members
• Relationship between superclass and subclass
• Constructors in subclasses
• Extends keyword
• Class Object
Resources:
• Java: How to Program early objects 10ed. – Deitel
• IntelliJ
• Lecture files and code examples in the book
• BOTS! OOPLectureFiles
o This has a ton of files for the BOTS assignment and they go along with the videos.