Skip to content

Advanced Programming II – SS3 Digital Technologies Lesson Note (First Term)

Download this term · ₦1,000

Lesson note at a glance

Subject
Digital Technologies
Class
SS3
Term
First Term
Topic
Advanced Programming II
Order
Topic 2 of 7 this term
Reading time
4 min

Object-oriented programming (OOP) is a style of coding that groups data and actions together into objects, so that code mirrors the real world. A class is the template, and an object is an item created from that template. This lesson covers classes and objects, encapsulation, inheritance and polymorphism.

Advertisement

Behavioural objectives

By the end of the lesson, students should be able to:

  • Describe an object in terms of its properties and behaviours.
  • Explain the difference between a class and an object.
  • Explain encapsulation and give two reasons for using it.
  • Explain inheritance using the terms superclass and subclass.
  • Explain polymorphism with an example.

What is object-oriented programming?

Before today, we mostly wrote “procedural” code, which is a long list of instructions for the computer to follow from top to bottom. The real world does not work like a list. It is made up of Objects.

Think about your phone. It is an “Object” that has:

  1. Properties (what it is): colour, battery percentage, screen size.
  2. Behaviours (what it does): makes a call, sends a text, takes a photo.

Object-Oriented Programming (OOP) is a style of coding where we group data and actions together into “Objects” so that our code mirrors the real world. It makes complex programs much easier to manage.

What is the difference between a class and an object?

The most confusing part of OOP is often the difference between a Class and an Object. Here is the simplest way to remember it:

  • The Class is the blueprint: If you want to build a house, you start with a drawing on paper. The drawing is not a house, because you cannot sleep in it. It only describes what a house should look like.
  • The Object is the house: When you use that drawing to build 10 different houses on a street, each of those physical houses is an “Object” (or an Instance).

In code, we write one Class (the template), and then we can create as many Objects from it as we want. Each object can have different details (like one house being blue and another being red), but they all follow the same blueprint.

Advertisement

What is encapsulation?

Imagine you are using a microwave. To heat your food, you press a button. You do not need to know how the wires are sparking inside or how the radiation is bouncing around. All that complex work is hidden inside the plastic shell.

In programming, this is called Encapsulation. We wrap our data and our methods (functions) inside a “capsule” (the class). We hide the complicated internal workings and only show the user the “buttons” they need to interact with.

Why use encapsulation?

  • Safety: It prevents people from accidentally changing important data.
  • Simplicity: It makes the code easier to use because you only see what is necessary.

What is inheritance?

In the real world, children inherit traits from their parents. In OOP, we can do the same thing with code.

Imagine we have a class called “Vehicle.” It has properties like Speed and Fuel. Instead of writing brand new code for a “Car,” a “Truck” and a “Motorcycle,” we can tell the computer that these three “inherit” from the Vehicle class.

  • The Parent (Superclass): Holds the general information (all vehicles move).
  • The Child (Subclass): Holds the specific information (a car has a boot, a motorcycle has a kickstand).

This saves us from typing the same code over and over again. If it works for the Parent, it automatically works for the Child.

What is polymorphism?

The word “Polymorphism” sounds like a difficult science term, but the idea is simple. It means “many shapes”.

Think of the command “Speak.”

  • If you tell a Dog to speak, it says “Woof.”
  • If you tell a Cat to speak, it says “Meow.”
  • If you tell a Human to speak, they say “Hello.”
Advertisement

The command is the same, but the result depends on who is doing the action.

In OOP, Polymorphism allows us to use the same function name for different objects. We can tell a whole list of different animals to run make_sound(), and the program knows which animal should bark and which should chirp.

Key terms checklist

  • Class: The template or blueprint.
  • Object: The actual item created from the template.
  • Encapsulation: Hiding the “inner workings” for safety.
  • Inheritance: Sharing code between a Parent and a Child.
  • Polymorphism: One action performing differently based on the object.

Evaluation

  1. What two things does an object have? Give one example of each for a phone.
  2. Explain the difference between a class and an object using the blueprint and house example.
  3. What is encapsulation? State two reasons for using it.
  4. In the Vehicle example, which is the superclass and which are the subclasses?
  5. What does polymorphism mean? Give an example using the command “Speak.”

Assignment

Choose a real-world item other than a phone (for example, a bicycle or a television). List two properties and two behaviours of the item. Then explain in two or three sentences how you would describe it as a class and one object created from that class.

This term's Digital Technologies topics

SS3 First Term · 7 topics

  1. Advanced Programming I
  2. Advanced Programming II
  3. Software Development Lifecycle
  4. Networking II
  5. Cloud and Virtualization
  6. Internet of Things (IoT) Application
  7. Data Protection and Backup System
Downloads

Get Digital Technologies as PDF and Word

Every week of SS3 Digital Technologies, First Term, formatted and ready to print. Ad-free, and the copy lock comes off.

Get this term Card, bank transfer, USSD or OPay

Advertisement

Lesson Notes for Other Classes

Print it or edit it in Word

Every note is free to read online. A PDF or Word copy of one subject costs ₦1,000 for one term, or ₦2,000 for all three terms.

Continue with GoogleContinue with Facebook

Sign in first, then choose your class and subject at checkout.