Polymorphism with Inheritance
CS2 / Java
Abstract
This activity introduces the concept of Polymorphism through a mechanism that the students have already used earlier in the course (using System.out.println to print Java objects in a human readable format) and invites students to “invent” the implementation of the println method. The students explore the concept of inheritance, one of ways to achieve polymorphism in Java, invent the rules behind inheritance (what methods can be used on what objects), and apply method overriding to prove that subclasses retain their original definition, even when used in a polymorphic way. After completing this activity the students are expected to be able to explain the concept of polymorphism, understand how polymorphism can be achieved with inheritance, and override superclass methods.
This activity was developed with NSF support through IUSE-1626765. You may request access to this activity via the following link: IntroCS-POGIL Activity Writing Program.
- Level: undergraduate
- Setting: computer classroom
- Activity type: Learning Cycle
- Discipline: Computer Science
- Course: CS2 / Java
- Keywords: inheritance, polymorphism
Downloads
Published
How to Cite
Issue
Section
License
Copyright of this work and the permissions granted to users of the PAC are defined in the PAC Activity User License.