Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Fundamentals of Object Oriented Programming Level Two ยท Lesson 2 of 8

Module One

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
2
Module 1: Abstraction, Interfaces & Abstract Classes for Young Coders
โญ Module 1 ยท Level Two

Abstraction, Interfaces
& Abstract Classes

๐ŸŽญ Hide the messy bits and share behaviour the smart way

๐ŸŽฏ What you'll learn in this module

  • โœ” What abstraction really means in code
  • โœ” The difference between abstract classes and interfaces
  • โœ” How to design contracts with interfaces
  • โœ” How to use default and static interface methods
  • โœ” How polymorphism through interfaces works
  • โœ” When to choose abstraction over inheritance
๐ŸŽญ
What Is Abstraction?
The Big Idea

Abstraction means showing only what matters and hiding the rest. When you drive a car, you use the steering wheel and pedals โ€” you don't need to understand the engine. The car abstracts the messy machinery behind simple controls.

In OOP, abstraction means exposing a simple, meaningful interface while hiding complicated implementation details. Your code can say player.play() without caring whether the player streams, reads a file, or plays from memory.

๐ŸŽฎ A game controller has buttons. You don't see the circuit board โ€” you just press "jump" and Mario jumps.
๐Ÿงฉ
Abstract Classes vs. Interfaces
The Core Tools

Both help you define abstraction, but they're different tools:

Feature Abstract Class Interface
Can hold state (fields)? Yes No (mostly constants)
Can provide method code? Yes, full and abstract methods Yes, with default methods
Multiple inheritance? No โ€” one parent only Yes โ€” implement many
Best forโ€ฆ Shared code + shared state Shared behaviour / contract
๐ŸŽ“ An abstract class is a course syllabus (partly filled in). An interface is a diploma โ€” a promise you can do certain things.
๐Ÿ“œ
Designing Contracts with Interfaces
Design

An interface is a contract: "any class that implements me promises to provide these methods." It says what can be done, not how.

Good interfaces are small and focused. A Flyable interface with just fly() is better than a Vehicle interface with 20 methods. Small contracts are easier to implement, test, and swap.

๐Ÿ“ An interface is a job description: "must be able to swim, teach, and cook." Whoever is hired must deliver those skills โ€” how they deliver is up to them.
๐Ÿงช
Default & Static Interface Methods
Modern Features

Modern languages like Java and C# allow interfaces to include default methods โ€” methods with code that implementing classes inherit automatically. This lets you add features to an interface without breaking every class that already implements it.

Static methods in interfaces are helper methods that belong to the interface itself, not to any implementing class. Use them for utility operations, like Flyable.canReach(altitude).

๐Ÿงฐ A default method is a builtโ€‘in feature every new phone gets automatically. A static method is a tool that the manufacturer offers to everyone, not a feature of the phone itself.
๐Ÿ”„
Polymorphism Through Interfaces
Power Move

This is the magic: you can hold any implementing object in a variable of the interface type. Call a method, and the correct implementation runs โ€” automatically.

Example: a List<Flyable> can hold a Bird, an Airplane, and a Drone. Loop through them and call fly() โ€” each one flies its own way. This is the heart of flexible, extensible design.

๐ŸŽฌ A director calls "Action!" โ€” every actor performs. The director doesn't need to know each actor's backstory; they just need to act.
โš–๏ธ
Abstraction Over Inheritance
Wisdom

Inheritance creates a strong parentโ€“child bond. Sometimes that's exactly what you want โ€” but often, an interface is a better fit because it's looser.

Think of it this way: inheritance says "is a" (a Dog is an Animal). An interface says "can do" (a Dog can swim). If a Robot can swim too, it shouldn't need to inherit from Animal โ€” it should just implement Swimmable.

๐Ÿฆ† A rubber duck can float (Swimmable) but it's not a living animal. Interfaces let it float without pretending to be one.
โš ๏ธ Common trap: New coders often overuse inheritance because it feels powerful. But if you find yourself writing five subclasses just to reuse three lines of code, that's your sign to reach for an interface or composition instead.

๐Ÿ› ๏ธ Hands-on activities (no boring stuff!)

1

Abstraction in real life: Pick three objects around you (a phone, a notebook, a door). Write down what you actually interact with and what you don't see. That's abstraction in action.

2

Shape builder: Create an abstract class Shape with an abstract method area() and a concrete method describe(). Add Circle and Rectangle subclasses. Show that describe() is shared but area() is not.

3

Flying club: Create an interface Flyable with fly(). Implement it in Bird, Airplane, and Drone. Put all three in a list and loop through them. Watch polymorphism happen.

4

Default method magic: Add a default method describeFlight() to the Flyable interface. Notice how every implementing class gets it for free โ€” without changing any of them.

5

Interface vs. inheritance: Make a Penguin that implements Swimmable but not Flyable. Then make a Duck that implements both. Explain why an interface is better than a deep inheritance tree here.

6

Contract design: Design a tiny interface (2โ€“3 methods) for a real scenario: Playable, Rechargeable, or Searchable. Implement it in two classes. Keep it small!

๐Ÿ†

By the end of this module, you'll be able to: explain abstraction, choose between abstract classes and interfaces, design small focused contracts, use default and static interface methods, and swap implementations polymorphically like a pro.

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’