Skip to content
Computer Science · Grade 11

Active learning ideas

Polymorphism and Interfaces

Active learning works for polymorphism and interfaces because these concepts require students to see how abstract designs translate into concrete behaviors. When students write and test code side-by-side, they experience firsthand how interfaces and abstract classes shape object interactions without getting lost in theory.

Ontario Curriculum ExpectationsCS.HS.P.4CS.HS.D.1
25–50 minPairs → Whole Class4 activities

Activity 01

Case Study Analysis30 min · Pairs

Pair Programming: Shape Interface Implementation

Pairs define a Shape interface with area() and perimeter() methods. Implement two subclasses like Circle and Rectangle. Create a polymorphic array of Shapes and compute totals, discussing output differences.

How does polymorphism allow a system to be extended without modifying existing code?

Facilitation TipDuring Pair Programming, provide starter code with a partially completed interface and abstract class so students focus on implementation details rather than setup.

What to look forPresent students with two code snippets: one using an interface and one using an abstract class to achieve similar functionality. Ask them to identify which is which and write one sentence explaining the primary difference in their approach.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

Activity 02

Case Study Analysis45 min · Small Groups

Small Groups: Animal Behavior Hierarchy

Groups create an abstract Animal class with makeSound() abstract and eat() concrete. Each member adds a subclass like Dog or Cat. Combine instances in a list for polymorphic calls, then share and test integrations.

What is the difference between an interface and an abstract class in system design?

Facilitation TipFor the Animal Behavior Hierarchy, give each group a different animal family (e.g., mammals, birds) to ensure varied solutions and richer class discussions.

What to look forPose the question: 'Imagine you are designing a system for managing different types of vehicles (cars, bikes, trucks). How would you use interfaces and abstract classes to ensure all vehicles can be `started` and `stopped`, but in unique ways?' Facilitate a class discussion on their proposed solutions.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

Activity 03

Case Study Analysis50 min · Whole Class

Whole Class: Plugin System Refactor

Project monolithic drawing code on screen. Class votes on interface needs, then pairs refactor into Drawable users. Regroup to run and verify polymorphic functionality works unchanged.

How do standardized interfaces facilitate collaboration between different development teams?

Facilitation TipIn the Plugin System Refactor, begin with a messy codebase so students see the immediate value of interfaces in organizing unrelated classes.

What to look forProvide students with a scenario: 'A new `Robot` class needs to be added to an existing system that already has `Dog` and `Cat` classes, all of which can `makeSound()`. The `makeSound()` method is implemented differently for each. Which concept, interface or abstract class, would be more appropriate for `makeSound()`, and why?'

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

Activity 04

Case Study Analysis25 min · Individual

Individual: Interface Contract Challenge

Provide a team interface contract. Students implement a custom class independently. Submit to class repository for polymorphic testing by peers, noting compatibility issues.

How does polymorphism allow a system to be extended without modifying existing code?

Facilitation TipFor the Interface Contract Challenge, require students to write unit tests alongside their implementations to reinforce the contract-focused nature of interfaces.

What to look forPresent students with two code snippets: one using an interface and one using an abstract class to achieve similar functionality. Ask them to identify which is which and write one sentence explaining the primary difference in their approach.

AnalyzeEvaluateCreateDecision-MakingSelf-Management
Generate Complete Lesson

A few notes on teaching this unit

Teach polymorphism by starting with concrete examples students can relate to, like shapes or vehicles, then gradually abstracting to interfaces. Avoid jumping straight to abstract classes; let students discover when they need shared code versus pure contracts. Research shows guided discovery with immediate feedback helps students correct misconceptions faster than lectures alone.

Successful learning looks like students confidently choosing between interfaces and abstract classes based on design needs, implementing methods correctly in subclasses, and explaining their choices with clear reasoning. You’ll know they’ve mastered it when they can refactor code to use polymorphism effectively and justify their design decisions.


Watch Out for These Misconceptions

  • During Pair Programming: Shape Interface Implementation, watch for students who treat interfaces and abstract classes as interchangeable.

    In this activity, pause pairs after 15 minutes to compare their interface and abstract class implementations side-by-side. Have them identify where code duplication could occur in the interface version and how the abstract class solves it.

  • During Animal Behavior Hierarchy, watch for students who believe polymorphism changes the actual type of an object.

    During this activity, ask each group to list the actual class and reference type for three different animals in their hierarchy. Then, have them trace method calls to observe that the actual object type determines behavior, not the reference.

  • During Plugin System Refactor, watch for students who try to instantiate interfaces or abstract classes directly.

    In this activity, include a compiler error in the starter code that shows an attempt to instantiate an interface. Have students troubleshoot the error and explain why it occurs, reinforcing the need for concrete subclasses.


Methods used in this brief