

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
8 questions
Perfect, Progressive, and Perfect Progressive
Presentation
•
8th - 12th Grade
9 questions
Proportions and Equivalent Ratios
Presentation
•
6th Grade
9 questions
Citing Textual Evidence
Presentation
•
6th - 8th Grade
8 questions
Imagery Lecture
Presentation
•
9th Grade
10 questions
Possessive adjectives -przymiotniki dzierżawcze
Presentation
•
4th - 8th Grade
10 questions
9/11
Presentation
•
9th - 12th Grade
10 questions
Unit Rate Intro
Presentation
•
7th Grade
10 questions
Connecting Conflict and Inference
Presentation
•
6th - 8th Grade
Popular Resources on Wayground
15 questions
Grade 3 Simulation Assessment 1
Quiz
•
3rd Grade
22 questions
HCS Grade 4 Simulation Assessment_1 2526sy
Quiz
•
4th Grade
16 questions
Grade 3 Simulation Assessment 2
Quiz
•
3rd Grade
19 questions
HCS Grade 5 Simulation Assessment_1 2526sy
Quiz
•
5th Grade
17 questions
HCS Grade 4 Simulation Assessment_2 2526sy
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
24 questions
HCS Grade 5 Simulation Assessment_2 2526sy
Quiz
•
5th Grade
20 questions
Math Review
Quiz
•
3rd Grade
Discover more resources for Information Technology (IT)
19 questions
Fire Safety
Quiz
•
KG - 2nd Grade
36 questions
8th Grade US History STAAR Review
Quiz
•
KG - University
20 questions
Capitalization in sentences
Quiz
•
KG - 4th Grade
19 questions
Disney Movies
Quiz
•
KG - 8th Grade
25 questions
Hidden Figures
Quiz
•
KG - 12th Grade
10 questions
Counting Nickels and Pennies
Quiz
•
KG - 2nd Grade
13 questions
Time
Quiz
•
KG - 2nd Grade
20 questions
Place Value
Quiz
•
KG - 3rd Grade