From the course: Java Object-Oriented Programming
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Discovering inheritance in foundational Java classes - Java Tutorial
From the course: Java Object-Oriented Programming
Discovering inheritance in foundational Java classes
- [Instructor] With a good foundation of inheritance, we can begin to explore how the Java programming language uses inheritance. Exploring more examples will help you better understand this object-oriented concept and recognize the scenarios it should be used in. One common Java class is the Stack class. Stack is the data structure and while we won't be exploring data structures too much in this course, we'll explore how this class uses inheritance to inherit behaviors and attributes from its superclass. Here we have a stack of characters and we've added a few characters to the stack with the push method. Then we've removed the characters with the pop method. When the characters are removed, they'll be removed in reverse order, meaning t will be removed, then a, then c. Running the code, we'll see cat displayed in reverse order. That's what makes this a stack. We can plop things on top and remove them in order of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
What is inheritance?2m 41s
-
(Locked)
Leveraging different types of inheritance2m 49s
-
(Locked)
Using inheritance to reduce code duplication4m 51s
-
(Locked)
Discovering inheritance in foundational Java classes3m 18s
-
(Locked)
Challenge: Reduce redundant code with inheritance1m 51s
-
(Locked)
Solution: Reduce redundant code with inheritance4m 37s
-
(Locked)
-
-
-