

Inheritance -OOP
Presentation
•
Information Technology (IT)
•
•
Practice Problem
•
Hard
Prosper Yeng
FREE Resource
10 Slides • 0 Questions
1
INT201: Object-Oriented Programming – Inheritance (C#)
By Dr. Prosper Yeng
2
Learning Objectives (Aligned with Bloom’s Taxonomy).By the end of this lesson, students will be able to:
Revise on the concepts of object, and class
Define inheritance in object-oriented programming.
Explain how inheritance enables code reusability and hierarchical class relationships.
Demonstrate single and multilevel inheritance in C# through practical code examples (e.g., Car → ElectricCar)
Differentiate between various types of inheritance
3
1. What Is an Object?
An object is a real-world entity that has data (attributes) and behavior (methods).
Example: A Car object has:
brand = Toyota
color = red
speed = 120
Methods: Start(), Stop()
Objects are created from templates or blueprints called classes.
4
2. What Is a Class?
A class is a blueprint that defines what data and actions its objects can have.
Example:
public class Car {
public string brand;
public int speed;
public void Start() {
Console.WriteLine("Car started");
}
public void Stop() {
Console.WriteLine("Car stopped");
}
}
5
3. Creating an Object instance from a Class
Example:
Car myCar = new Car();
myCar.brand = "Toyota";
myCar.speed = 120;
myCar.Start();
Output:
Car started
6
Inheritance is an object-oriented programming (OOP) principle
Allows a new class (called the child or derived class)
To acquire the properties and behaviors of an existing class (called the parent or base class).
Example: ElectricCar inherits all properties from Car and adds new ones like ChargeBattery().
4. What Is Inheritance?
7
5. Example: Car → ElectricCar
public class Car {
public string brand;
public void Start()
{
Console.WriteLine("Car started");
}
}
public class ElectricCar : Car {
public int batteryLevel;
public void ChargeBattery()
{
Console.WriteLine("Battery charging...");
batteryLevel = 100;
}
}
8
6. Using the ElectricCar Class
ElectricCar myTesla = new ElectricCar();
myTesla.brand = "Tesla";
myTesla.Start(); // from Car
myTesla.ChargeBattery(); // from ElectricCar
Output:
Car started
Battery charging...
9
7. Calling Parent Method Using base
10
8.Recap
Object – real-world entity
Class – blueprint for objects
Inheritance – child uses parent’s code
Inheritance types
Next class:
base – calls parent method
override – modifies parent behavior
Inheritance type implementation
INT201: Object-Oriented Programming – Inheritance (C#)
By Dr. Prosper Yeng
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
6 questions
Student Device Contract 2025-26 S1
Presentation
•
7th - 9th Grade
9 questions
Argumentative Text
Presentation
•
8th Grade
7 questions
Identifying key ideas
Presentation
•
6th - 8th Grade
9 questions
Scatter Plots and Lines of Trend
Presentation
•
8th - 9th Grade
10 questions
Unit Rate and Graphs
Presentation
•
7th Grade
10 questions
Theme Review Lesson
Presentation
•
4th Grade
7 questions
Realidades 1 2a Listening Activity 6
Presentation
•
9th Grade
7 questions
Elapsed Time
Presentation
•
3rd Grade
Popular Resources on Wayground
10 questions
GPA Lesson
Presentation
•
9th - 12th Grade
7 questions
Albert Einstein
Quiz
•
3rd Grade
31 questions
Bridge A Review
Quiz
•
3rd Grade
6 questions
Blue Sue and Red Ruth
Quiz
•
3rd Grade
8 questions
(Day12 HW) Inverse Trig Ratios
Quiz
•
9th Grade
20 questions
Summer Geometry QUIZ (Week3)
Quiz
•
9th Grade
16 questions
Theme Practice
Quiz
•
7th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade