Module 3 · Lesson 2 of 28/22 in the course~16 min
Module lessons (2/2)
Polymorphism and Abstract Classes
Lesson preview5 hands-on exercises readyCourse Java · Module 3 — OOP Advanced
Dynamic dispatch at runtime, upcasting, template method pattern, and blueprint modeling with abstract class.
What you'll learn in this lesson
- Exploit polymorphism to write generic code on a base type that invokes specialized implementations at runtime.
- Understanding dynamic dispatch: It is the actual object on the Heap, not the type of the variable on the Stack, that decides which method is executed.
- Model shared contracts and abstract methods using
abstract class.
Overview
Polymorphism ("many forms") allows objects of different subclasses to be treated uniformly through a supertype reference.
If a base class doesn't know how to implement an action in general (for example getArea() for any Shape), declare the class and that method abstract:
Sections covered in this lesson
- 11. Upcasting and Dynamic Method Dispatch
- 22. Abstract Classes and Methods (
abstract class) - 33. Uniform Processing on Polymorphic Collections
- 44.
abstractvs Partial Abstract Subclass - 5Try it yourself
Pro Lesson · Module 3 — OOP Advanced
Unlock "Polymorphism and Abstract Classes" and the full Course Java curriculum
Dynamic dispatch at runtime, upcasting, template method pattern, and blueprint modeling with `abstract class`.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course Java plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.