SlideShare a Scribd company logo
Introduction to
OOP Concepts
BY: SAMUEL ANSONG
Pre-Requisites
• Familiarity with functions and types
• Basic understanding of a class
• Has an overall Introduction to programming
• We will be using C# for code samples
Pre-Requisite Check
1. Write a simple function to add all numbers in the array below
int [] array = new int[] {2,4,5,6,7,8,8,9,0,10,5,7}
Hint
<visibility> <return type> <name>(<parameters>)
{
<function code>
}
You can logon Here -> C# Online Compiler | .NET Fiddle (dotnetfiddle.net) and complete your
code.
Answer and Modification
1. Overload the function to take 3 numbers
2. Overload the method to take any amount of numbers
3. Change the function into a lambda format
Structure
Procedural Oriented Programming Overview
Limitations of POP
Object Oriented Programming Overview
• Encapsulation
• Inheritance
• Polymorphism
• Abstraction
Core Components
• Access Modifiers
• Static Class and Methods
Key Terms
Procedural Oriented Programming
• C , Pascal, FORTRAN, and similar languages are procedural languages
• Each Statement in the language tells the computer to do something
• Get some Input
• Add these numbers
• Divide by 4
• Display the number
A program in a procedural language is a list of
instructions
Divided Into Functions
• Procedural program is divided into functions
• Each function has clearly defined purpose and how it interfaces with other
functions in the program
• One can also further extend functions by grouping several functions together
into a larger entity called Modules .
Divided Into Functions
• In Multi-Function program important data items
are placed as Global so that they maybe
accessed by all functions
• Each function may also have its own local data
Limitations for POP
• Since all functions have accessed to the Global Variable , new functions
accidentally created can corrupt the data
• We can access the data of one function from other since there is no
protection
• In a large program it is difficult to trace what data is used by which function
• If new data is added , all the functions are to be modified to access this data
Object Oriented Programming
• OOP was introduced to overcome flaws in the procedural
approach to programming
• Such as lack of Reusability and Maintainability
• The Fundamental idea behind OOP is to combine into a
single unit both data and functions that operate on them.
• Such a unit is called an Object .
Objects?
In the real world, just about anything can be seen as an object:
car, dog, person, department, city, etc. These
have state and behavior. For example, a dog's state is its color,
breed and name; its behavior is the way it barks, runs or wags its
tail. Objects in OOP are quite similar
Example
Identify the Properties (State) and Behavior
(Methods) of Your Bicycle
Objects Continued…..
Object Oriented Programming
• In OOP, problem is divided into number of entities called objects
and then builds data and functions around these objects
• It ties the data more closely to the functions that operate it and
protects it from accidental modification from the outside functions
• Data of an object can only be accessed by the functions associated
with that object
• Communication of the objects done through functions.
Classes
• Classes are user-defined data types
• Objects are variables of a class
• Once a class has been defined, we can create any number of
objects from the Class
• A class thus can be said as a collection of similar objects of same
type.
Example
• Let us consider a software that involves renting cars.
• We can have a class and objects as below
Example
Let us consider a software that involves a zoo.
What are some of the classes and objects to be
created .
Answer
Core Concepts
Encapsulation
• Encapsulation is the first pillar or principle of object-oriented
programming
• In simple words, ā€œEncapsulation is a process of binding data
members (variables, properties) and member
functions(methods) into a single unitā€
• And a Class is the best example of encapsulation
• Data Hiding from all external Classes
Encapsulation
Encapsulation in Real Life
•Has prescription
•Does not have direct
contact to the medicines
Patient
•Has Access to the medicine
•Returns the right medicine
•Reduces risk of you getting
wrong medicine
Chemist •Can only be accessed by
chemists
•Several medicines available
for different treatments
Medicines
Encapsulation in OOP
•Has no direct access to
data in the medicine class
External
Classes
•Controls access and
manipulation of data in the
medicine class
•They are wrapped in the
class
Functions •Medicine Class
•Contains both member
functions and Variables
•Determines how accessible
the data is to outside world
Medicines
Encapsulation in OOP
So, Encapsulation means hiding the important features
of a class which has no usefulness being
exposed to outside of the class and exposing only the
necessary things of the class.
Abstraction
Abstraction is about describing something at a
conceptual level while leaving out the details.
example, we may talk about a vehicle without
being explicit if it's a ship or a car.
Example of Abstraction
When using the tv remote control, you do not
bother about how pressing a key in the remote
changes the channel on the TV. You Just know
that pressing the ā€œ+ā€ volume button will increase
the volume.
Example of Abstraction
• A class can be abstract as well meaning , it can provide you
functions without their implementation
• For example, if our class was a remote control , it will give
us the method IncreaseVolume() without details of how It
will be done . Such a method is called an abstract method
Example of Abstraction
• You cannot instantiate this class
Animal myObj = new Animal(); // Will generate an
error
• You can only Inherit this class
Inheritance
• The mechanism of deriving a new class from an old class is called
inheritance or derivation
• The Old class is known as base class while new class is known as
derived class or sub class
• Inheritance is the most powerful feature of OOP.
• Gives the sub class access to methods of based class
Example
If a child is as Tall as his dad and Fair as his mom
, we usually say the child has inherited these
features from his father and mother.
Example
using System;
namespace MyApplication
{
class Vehicle // Base class
{
public string brand = "Ford"; // Vehicle field
public void honk() // Vehicle method
{
Console.WriteLine("Tuut, tuut!");
}
}
}
• The Base class here is Vehicle
• It has Properties (Brand) and an implemented
Method honk
Example
using System;
namespace MyApplication
{
class Car : Vehicle // Derived class
{
public string modelName = "Mustang"; // Car field
}
}
• The Base class here is Vehicle
• The Car class is inheriting the vehicle class and thus
Will have access to the honk method in the Vehicle class.
• Inheritance is shown by the ā€œ:ā€ sign . Colon.
Example Code Snippet
using System;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
// Create a myCar object
Car myCar = new Car();
// Call the honk() method (From the Vehicle class) on the myCar object
myCar.honk();
// Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class
Console.WriteLine(myCar.brand + " " + myCar.modelName);
}
}
}
Inheritance
• Through Effective use of inheritance , you can save a lot of time in your
programming and reduces errors
• This will also increase the quality of the work and productivity
Polymorphism
• Polymorphism means "many forms", and it occurs
when we have many classes that are related to each
other by inheritance
• Inheritance lets us inherit fields and methods from
another class. Polymorphism uses those methods
to perform different tasks. This allows us to perform
a single action in different ways.
Example
For example, think of a base class called Animal that
has a method called animalSound(). Derived classes of
Animals could be Pigs, Cats, Dogs, Birds - And they
also have their own implementation of an animal
sound (the pig oinks, and the cat meows, etc.):
Example
class Animal // Base class (parent)
{
public void animalSound()
{
Console.WriteLine("The animal makes a sound");
}
}
class Pig : Animal // Derived class (child)
{
public void animalSound()
{
Console.WriteLine("The pig says: wee wee");
}
}
Next Lecture
Object Oriented Programming Implementation
Building a Game with C#
Unity 3D and C#
• Encapsulation
• Inheritance
• Polymorphism
• Abstraction
Modelling our Game as OOP

More Related Content

PPTX
Solid principles
Monica Rodrigues
Ā 
PDF
Retrofit
Amin Cheloh
Ā 
PPT
JAVA OOP
Sunil OS
Ā 
PPT
C# Basics
Sunil OS
Ā 
PPTX
Networking in Java
Tushar B Kute
Ā 
PPT
Java Basics
shivamgarg_nitj
Ā 
PPT
Java Basics
Sunil OS
Ā 
Solid principles
Monica Rodrigues
Ā 
Retrofit
Amin Cheloh
Ā 
JAVA OOP
Sunil OS
Ā 
C# Basics
Sunil OS
Ā 
Networking in Java
Tushar B Kute
Ā 
Java Basics
shivamgarg_nitj
Ā 
Java Basics
Sunil OS
Ā 

What's hot (20)

PPTX
Introduction to Object Oriented Programming
Moutaz Haddara
Ā 
PPT
Android JNI
Siva Ramakrishna kv
Ā 
PPTX
SOLID & IoC Principles
Pavlo Hodysh
Ā 
PPTX
Control structures in java
VINOTH R
Ā 
PDF
Introduction to kotlin coroutines
NAVER Engineering
Ā 
PPTX
Collections in-csharp
Lakshmi Mareddy
Ā 
PPT
C# basics
Dinesh kumar
Ā 
PPTX
Solid principles
Toan Nguyen
Ā 
PPT
Oops concepts in php
CPD INDIA
Ā 
PPT
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
Ā 
PPTX
Exception Handling in C#
Abid Kohistani
Ā 
PPTX
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
Ā 
PDF
Java threads
Prabhakaran V M
Ā 
PPTX
MVC Framework
Ashton Feller
Ā 
PPT
Object-oriented concepts
BG Java EE Course
Ā 
PDF
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
Ā 
PPT
JDBC – Java Database Connectivity
Information Technology
Ā 
PPT
Object Oriented Programming with Java
backdoor
Ā 
PPTX
Java 101 Intro to Java Programming
agorolabs
Ā 
PPT
Aggregating Data Using Group Functions
Salman Memon
Ā 
Introduction to Object Oriented Programming
Moutaz Haddara
Ā 
Android JNI
Siva Ramakrishna kv
Ā 
SOLID & IoC Principles
Pavlo Hodysh
Ā 
Control structures in java
VINOTH R
Ā 
Introduction to kotlin coroutines
NAVER Engineering
Ā 
Collections in-csharp
Lakshmi Mareddy
Ā 
C# basics
Dinesh kumar
Ā 
Solid principles
Toan Nguyen
Ā 
Oops concepts in php
CPD INDIA
Ā 
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
Ā 
Exception Handling in C#
Abid Kohistani
Ā 
[OOP - Lec 01] Introduction to OOP
Muhammad Hammad Waseem
Ā 
Java threads
Prabhakaran V M
Ā 
MVC Framework
Ashton Feller
Ā 
Object-oriented concepts
BG Java EE Course
Ā 
Java Tutorial | Java Programming Tutorial | Java Basics | Java Training | Edu...
Edureka!
Ā 
JDBC – Java Database Connectivity
Information Technology
Ā 
Object Oriented Programming with Java
backdoor
Ā 
Java 101 Intro to Java Programming
agorolabs
Ā 
Aggregating Data Using Group Functions
Salman Memon
Ā 
Ad

Similar to Object Oriented Programming (OOP) Introduction (20)

PDF
JAVA-PPT'S.pdf
AnmolVerma363503
Ā 
PPTX
object oriented programing lecture 1
Geophery sanga
Ā 
PPTX
Introduction to oop
colleges
Ā 
PPTX
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
Ā 
PPTX
JAVA-PPT'S.pptx
RaazIndia
Ā 
PPTX
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
Ā 
PDF
80410172053.pdf
WrushabhShirsat3
Ā 
PDF
Cs2305 programming paradigms lecturer notes
Saravanakumar viswanathan
Ā 
PPTX
Introduction to OOP concepts
Ahmed Farag
Ā 
PPT
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
Ā 
PPT
Md02 - Getting Started part-2
Rakesh Madugula
Ā 
PPTX
oop.pptx
KabitaParajuli3
Ā 
PPTX
Class and Objects in python programming.pptx
Rajtherock
Ā 
PPTX
Introduction to OOPs second year cse.pptx
solemanhldr
Ā 
PPT
the education purpose of software C++.ppt
FarookMohamed12
Ā 
PPTX
C++ first s lide
Sudhriti Gupta
Ā 
PPTX
Presentation 4th
Connex
Ā 
PPTX
Object oriented programming
baabtra.com - No. 1 supplier of quality freshers
Ā 
PPTX
Object Oriented Programming.pptx
ShuvrojitMajumder
Ā 
JAVA-PPT'S.pdf
AnmolVerma363503
Ā 
object oriented programing lecture 1
Geophery sanga
Ā 
Introduction to oop
colleges
Ā 
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
Ā 
JAVA-PPT'S.pptx
RaazIndia
Ā 
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
Ā 
80410172053.pdf
WrushabhShirsat3
Ā 
Cs2305 programming paradigms lecturer notes
Saravanakumar viswanathan
Ā 
Introduction to OOP concepts
Ahmed Farag
Ā 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
Ā 
Md02 - Getting Started part-2
Rakesh Madugula
Ā 
oop.pptx
KabitaParajuli3
Ā 
Class and Objects in python programming.pptx
Rajtherock
Ā 
Introduction to OOPs second year cse.pptx
solemanhldr
Ā 
the education purpose of software C++.ppt
FarookMohamed12
Ā 
C++ first s lide
Sudhriti Gupta
Ā 
Presentation 4th
Connex
Ā 
Object Oriented Programming.pptx
ShuvrojitMajumder
Ā 
Ad

Recently uploaded (20)

PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
Ā 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
Ā 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
Ā 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
PDF
Architecture of the Future (09152021)
EdwardMeyman
Ā 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
Ā 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
Ā 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
PDF
This slide provides an overview Technology
mineshkharadi333
Ā 
PDF
Doc9.....................................
SofiaCollazos
Ā 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
Ā 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
Ā 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
Ā 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
Ā 
Presentation about Hardware and Software in Computer
snehamodhawadiya
Ā 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
Ā 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
Ā 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
Architecture of the Future (09152021)
EdwardMeyman
Ā 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
Brief History of Internet - Early Days of Internet
sutharharshit158
Ā 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
Ā 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
This slide provides an overview Technology
mineshkharadi333
Ā 
Doc9.....................................
SofiaCollazos
Ā 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
Ā 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
Ā 

Object Oriented Programming (OOP) Introduction

  • 2. Pre-Requisites • Familiarity with functions and types • Basic understanding of a class • Has an overall Introduction to programming • We will be using C# for code samples
  • 3. Pre-Requisite Check 1. Write a simple function to add all numbers in the array below int [] array = new int[] {2,4,5,6,7,8,8,9,0,10,5,7} Hint <visibility> <return type> <name>(<parameters>) { <function code> } You can logon Here -> C# Online Compiler | .NET Fiddle (dotnetfiddle.net) and complete your code.
  • 4. Answer and Modification 1. Overload the function to take 3 numbers 2. Overload the method to take any amount of numbers 3. Change the function into a lambda format
  • 5. Structure Procedural Oriented Programming Overview Limitations of POP Object Oriented Programming Overview • Encapsulation • Inheritance • Polymorphism • Abstraction Core Components • Access Modifiers • Static Class and Methods Key Terms
  • 6. Procedural Oriented Programming • C , Pascal, FORTRAN, and similar languages are procedural languages • Each Statement in the language tells the computer to do something • Get some Input • Add these numbers • Divide by 4 • Display the number A program in a procedural language is a list of instructions
  • 7. Divided Into Functions • Procedural program is divided into functions • Each function has clearly defined purpose and how it interfaces with other functions in the program • One can also further extend functions by grouping several functions together into a larger entity called Modules .
  • 8. Divided Into Functions • In Multi-Function program important data items are placed as Global so that they maybe accessed by all functions • Each function may also have its own local data
  • 9. Limitations for POP • Since all functions have accessed to the Global Variable , new functions accidentally created can corrupt the data • We can access the data of one function from other since there is no protection • In a large program it is difficult to trace what data is used by which function • If new data is added , all the functions are to be modified to access this data
  • 10. Object Oriented Programming • OOP was introduced to overcome flaws in the procedural approach to programming • Such as lack of Reusability and Maintainability • The Fundamental idea behind OOP is to combine into a single unit both data and functions that operate on them. • Such a unit is called an Object .
  • 11. Objects? In the real world, just about anything can be seen as an object: car, dog, person, department, city, etc. These have state and behavior. For example, a dog's state is its color, breed and name; its behavior is the way it barks, runs or wags its tail. Objects in OOP are quite similar
  • 12. Example Identify the Properties (State) and Behavior (Methods) of Your Bicycle
  • 14. Object Oriented Programming • In OOP, problem is divided into number of entities called objects and then builds data and functions around these objects • It ties the data more closely to the functions that operate it and protects it from accidental modification from the outside functions • Data of an object can only be accessed by the functions associated with that object • Communication of the objects done through functions.
  • 15. Classes • Classes are user-defined data types • Objects are variables of a class • Once a class has been defined, we can create any number of objects from the Class • A class thus can be said as a collection of similar objects of same type.
  • 16. Example • Let us consider a software that involves renting cars. • We can have a class and objects as below
  • 17. Example Let us consider a software that involves a zoo. What are some of the classes and objects to be created .
  • 20. Encapsulation • Encapsulation is the first pillar or principle of object-oriented programming • In simple words, ā€œEncapsulation is a process of binding data members (variables, properties) and member functions(methods) into a single unitā€ • And a Class is the best example of encapsulation • Data Hiding from all external Classes
  • 22. Encapsulation in Real Life •Has prescription •Does not have direct contact to the medicines Patient •Has Access to the medicine •Returns the right medicine •Reduces risk of you getting wrong medicine Chemist •Can only be accessed by chemists •Several medicines available for different treatments Medicines
  • 23. Encapsulation in OOP •Has no direct access to data in the medicine class External Classes •Controls access and manipulation of data in the medicine class •They are wrapped in the class Functions •Medicine Class •Contains both member functions and Variables •Determines how accessible the data is to outside world Medicines
  • 24. Encapsulation in OOP So, Encapsulation means hiding the important features of a class which has no usefulness being exposed to outside of the class and exposing only the necessary things of the class.
  • 25. Abstraction Abstraction is about describing something at a conceptual level while leaving out the details. example, we may talk about a vehicle without being explicit if it's a ship or a car.
  • 26. Example of Abstraction When using the tv remote control, you do not bother about how pressing a key in the remote changes the channel on the TV. You Just know that pressing the ā€œ+ā€ volume button will increase the volume.
  • 27. Example of Abstraction • A class can be abstract as well meaning , it can provide you functions without their implementation • For example, if our class was a remote control , it will give us the method IncreaseVolume() without details of how It will be done . Such a method is called an abstract method
  • 28. Example of Abstraction • You cannot instantiate this class Animal myObj = new Animal(); // Will generate an error • You can only Inherit this class
  • 29. Inheritance • The mechanism of deriving a new class from an old class is called inheritance or derivation • The Old class is known as base class while new class is known as derived class or sub class • Inheritance is the most powerful feature of OOP. • Gives the sub class access to methods of based class
  • 30. Example If a child is as Tall as his dad and Fair as his mom , we usually say the child has inherited these features from his father and mother.
  • 31. Example using System; namespace MyApplication { class Vehicle // Base class { public string brand = "Ford"; // Vehicle field public void honk() // Vehicle method { Console.WriteLine("Tuut, tuut!"); } } } • The Base class here is Vehicle • It has Properties (Brand) and an implemented Method honk
  • 32. Example using System; namespace MyApplication { class Car : Vehicle // Derived class { public string modelName = "Mustang"; // Car field } } • The Base class here is Vehicle • The Car class is inheriting the vehicle class and thus Will have access to the honk method in the Vehicle class. • Inheritance is shown by the ā€œ:ā€ sign . Colon.
  • 33. Example Code Snippet using System; namespace MyApplication { class Program { static void Main(string[] args) { // Create a myCar object Car myCar = new Car(); // Call the honk() method (From the Vehicle class) on the myCar object myCar.honk(); // Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class Console.WriteLine(myCar.brand + " " + myCar.modelName); } } }
  • 34. Inheritance • Through Effective use of inheritance , you can save a lot of time in your programming and reduces errors • This will also increase the quality of the work and productivity
  • 35. Polymorphism • Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance • Inheritance lets us inherit fields and methods from another class. Polymorphism uses those methods to perform different tasks. This allows us to perform a single action in different ways.
  • 36. Example For example, think of a base class called Animal that has a method called animalSound(). Derived classes of Animals could be Pigs, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the pig oinks, and the cat meows, etc.):
  • 37. Example class Animal // Base class (parent) { public void animalSound() { Console.WriteLine("The animal makes a sound"); } } class Pig : Animal // Derived class (child) { public void animalSound() { Console.WriteLine("The pig says: wee wee"); } }
  • 38. Next Lecture Object Oriented Programming Implementation Building a Game with C# Unity 3D and C# • Encapsulation • Inheritance • Polymorphism • Abstraction Modelling our Game as OOP