SlideShare a Scribd company logo
OOPS – General Understanding in .NET
• Introduction to OOPS
• Class and Object
• Encapsulation
• Inheritance
• Polymorphism
• Interfaces
• Delegate
• Access Modifiers
• Namespace
Agenda
About OOPS
OOPS is a programming language organized around objects (data) rather than action
and logic.
It is composed of self sufficient modules (“Class”), each instance (“Object”)
contains information to manipulate its data (“Members”)
Four main features of OOPS are
• Abstraction
• Encapsulation
• Polymorphism
• Inheritance
Object and Class
• Object is an instance of a class
• Object has state, behavior, and identity
• Object can be created by using the NEW keyword
• Communicates with other objects through message passing
Object
• It is a user defined data type
• In OOP you program a class as a template for a specific object
or groups ob objects that will always have the same features.
• Other types of classes
• Abstract class
• Static class
Class
Encapsulation
Encapsulation is the process of binding/wrapping
the data and methods into a single entity
Encapsulation is realized through the classes.
Encapsulation guarantees the integrity of the data
in the object
Three main parts of Object
• Interface
• Implementation or Behavior
• Member or Instance variables
Access modifiers
are used to
implement
encapsulation
It reduces system
complexity and
thus increases
robustness, by
limiting the
interdependencies
Abstraction is
achieved through
encapsulation
Object and
Properties are
examples for
encapsulation
Inheritance
Inheritance is a way to form new CLASSES using classes that have
already been.
Inheritance is employed to help REUSE existing code with little or no
modification.
The new classes, known as Sub-classes (or derived classes), inherit
attributes and behavior of the pre-existing classes, which are referred to
as Super-classes (or ancestor classes).
The inheritance relationship of SUB and SUPER CLASSES gives rise to a
HIERARCHY.
Inheritance
Purpose
• Reuse, extend, and modify the
behavior defined in other
classes
• Allows to build a hierarchy of
related classes
Only single inheritance is allowed
in .NET
Three types of inheritance
• Implementation
• Interface
• Visual
To avoid inheritance, we need to
use ‘sealed’ keyword
Polymorphism
Many forms of a single object is
called Polymorphism.
Polymorphism is important not
only to the derived classes, but
to the base classes as well.
It allows you to invoke methods
of derived class through base
class reference during runtime.
It has the ability for classes to
provide different
implementations of methods that
are called through the same
name.
Polymorphism Contd…
Polymorphism is of two types:
• Compile time polymorphism/Overloading
• Runtime polymorphism/Overriding
Compile Time Polymorphism
• Compile time polymorphism is method and operators
overloading. It is also called early binding.
• In method overloading method performs the
different task at the different input parameters.
Polymorphism Contd…
• Runtime time polymorphism is done
using inheritance and virtual
functions. Method overriding is
called runtime polymorphism. It is
also called late binding.
• When overriding a method, you
change the behavior of the method
for the derived class. Overloading
a method simply involves having
another method with the same
prototype.
When and why to use method
overloading ?
Runtime Time
Polymorphism
Function Overloading
Using same
name for
two or more
functions
Functions
should differ
with the
function
signature
Function
signature is
1.Number of
parameters
2.Different
data types of
parameters
3.Sequence of
parameters
Return type
is NOT part
of function
signature
Operator overloading
Using
• Static member
functions using the
operator keyword
Syntax
• <access modifier>
<Class Name>
operator <operator
symbol> (parameter
list)
• {
• .Do something
• }
Few types of
operator overloading
• Unary operator
overloading
• Binary operator
overloading
Abstract class
Purpose of an abstract class is to provide a common
definition of a base class
An abstract class cannot be instantiated
Abstract classes may also define abstract methods
Use abstract keyword
Abstract methods have no implementation
Use override keyword to implement abstract methods
Virtual members
Virtual members enable derived classes to extend a base class
Base class member should use virtual and derived class member should use
override
Fields cannot be virtual
Override virtual members in the base class
Inherit base class method without overriding it
Define new non-virtual implementation that hide the base class
implementations
The derived class can choose whether to
Interfaces
Interfaces describe a group of related functionalities
Interfaces are defined by using the INTERFACE keyword
Non-abstract type inheriting the interface must implement all its
members
Interfaces contain no implementation of methods
An interface cannot be instantiated directly
Interfaces Contd…
Classes can inherit from more
than one interface
An interface can itself inherit
from multiple interfaces
Interfaces members are
automatically public
The member of class
implementing interface member
must be of the following
• Public and non-static
• Same name and signature
Difference
Abstract Class Interface
Abstract class may contain concrete
methods
Interface contains methods that must
be abstract
Abstract class may contain non-public
members.
Members in an interface are public by
default
whereas abstract class is used to
"extends".
Interface is used to "implements";
Single inheritance Multiple inheritance
Abstract class can "extends" another
class and "implements" multiple
interfaces.
Interface can "extends" another
interface
One class can only "extends" one
super class
interface is more flexible than
abstract class because it "implements"
multiple interfaces.
Any class can extend an abstract
class.
only an interface can extend another
interface
Delegates
Delegates Contd…
Multi cast delegate
• Refer to multiple methods
of matching signature
• Derived from
System.MulticastDelegate
class
• Example: to call two
methods on a button click
event
Steps to use delegates
• Declare a delegate with a
function signature
• Instantiate the declared
delegate
• Use the delegate to
execute a function
Access Modifiers
All types and type members have
an accessibility level
which controls whether they can
be used from other code in your
assembly or other assemblies.
Access modifiers are
determined by the scope of
visibility for variables and
methods.
Used to implement encapsulation
and abstraction
Access Modifiers
Types of access
modifiers
• private
• public
• protected
• internal
• internal
protected
Default access
modifier for class
is internal
Default access
modifier for data
member is private
Namespace
The namespace keyword is used to declare a scope.
This namespace scope lets you organize code and
gives you a way to create globally unique types.
Within a namespace, you can declare one or more of the following types:
1.another namespace
2.class
3.interface
4.struct
5.enum
6.Delegate
namespace Name1
{
class A {}
}
namespace Name2
{
class A {}
}
We can also use nested namespace
namespace csharp_example
{
// Program start class
class NamespaceCE
{
// Main begins program execution.
public static void Main()
{
// Write to console
Console.WriteLine("This is the new C# Example Namespace.");
}
}
}
Namespace Example
OOPS – General Understanding in .NET

More Related Content

What's hot (20)

PPTX
Packages and Interfaces
AkashDas112
 
PPTX
Inner Classes & Multi Threading in JAVA
Tech_MX
 
PPTX
More oop in java
SAGARDAVE29
 
PPTX
Introduction to oop and java fundamentals
AnsgarMary
 
PPTX
Class Members Access/Visibility Guide (Checklist)
Jayasree Perilakkalam
 
PPT
L7 inheritance
teach4uin
 
PPTX
Object oriented programming 3 object oriented concepts
Vaibhav Khanna
 
PDF
Java packages
Jeffrey Quevedo
 
PPT
Inheritance and Polymorphism
BG Java EE Course
 
DOCX
Class notes(week 7) on packages
Kuntal Bhowmick
 
PPTX
Inheritance in Java
Ferdin Joe John Joseph PhD
 
PDF
Inheritance
Ravi_Kant_Sahu
 
PPTX
Classes and objects
Anil Kumar
 
PPTX
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Simplilearn
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPT
Object Oriented Programming In .Net
Greg Sohl
 
PPTX
Input & output
SAIFUR RAHMAN
 
PDF
Methods and constructors
Ravi_Kant_Sahu
 
PPT
Unit 3 Java
arnold 7490
 
PPT
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Packages and Interfaces
AkashDas112
 
Inner Classes & Multi Threading in JAVA
Tech_MX
 
More oop in java
SAGARDAVE29
 
Introduction to oop and java fundamentals
AnsgarMary
 
Class Members Access/Visibility Guide (Checklist)
Jayasree Perilakkalam
 
L7 inheritance
teach4uin
 
Object oriented programming 3 object oriented concepts
Vaibhav Khanna
 
Java packages
Jeffrey Quevedo
 
Inheritance and Polymorphism
BG Java EE Course
 
Class notes(week 7) on packages
Kuntal Bhowmick
 
Inheritance in Java
Ferdin Joe John Joseph PhD
 
Inheritance
Ravi_Kant_Sahu
 
Classes and objects
Anil Kumar
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Simplilearn
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Object Oriented Programming In .Net
Greg Sohl
 
Input & output
SAIFUR RAHMAN
 
Methods and constructors
Ravi_Kant_Sahu
 
Unit 3 Java
arnold 7490
 
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 

Similar to OOPS – General Understanding in .NET (20)

PPTX
Inheritance.pptx
PRIYACHAURASIYA25
 
PPTX
Object Oriented Programming C#
Muhammad Younis
 
PPTX
Introduction to oop
colleges
 
PPT
Opps
Lalit Kale
 
PPTX
Object oriented programming
MH Abid
 
PPTX
Better Understanding OOP using C#
Chandan Gupta Bhagat
 
ODP
Ppt of c++ vs c#
shubhra chauhan
 
PPTX
CSharp_03_Inheritance_introduction_with_examples
Ranjithsingh20
 
PDF
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
markbrianBautista
 
DOCX
Question and answer Programming
Inocentshuja Ahmad
 
PPTX
Object oriented programming
Vasilios Kuznos
 
PPTX
OOP-Advanced Programming with c++
Mohamed Essam
 
PPTX
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
PPT
Inheritance
abhay singh
 
PPT
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
PDF
Net Interview-Questions 1 - 16.pdf
PavanNarne1
 
PPTX
OOP Presentation.pptx
DurgaPrasadVasantati
 
Inheritance.pptx
PRIYACHAURASIYA25
 
Object Oriented Programming C#
Muhammad Younis
 
Introduction to oop
colleges
 
Object oriented programming
MH Abid
 
Better Understanding OOP using C#
Chandan Gupta Bhagat
 
Ppt of c++ vs c#
shubhra chauhan
 
CSharp_03_Inheritance_introduction_with_examples
Ranjithsingh20
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
markbrianBautista
 
Question and answer Programming
Inocentshuja Ahmad
 
Object oriented programming
Vasilios Kuznos
 
OOP-Advanced Programming with c++
Mohamed Essam
 
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
Inheritance
abhay singh
 
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
 
Net Interview-Questions 1 - 16.pdf
PavanNarne1
 
OOP Presentation.pptx
DurgaPrasadVasantati
 
Ad

More from Sabith Byari (13)

DOC
Sabith_Byari-Resume_Updated
Sabith Byari
 
PPT
C your C
Sabith Byari
 
PPTX
Simplification
Sabith Byari
 
PPT
Seating arr
Sabith Byari
 
PPTX
Ratio
Sabith Byari
 
PPT
Puzzles
Sabith Byari
 
PPT
Pie
Sabith Byari
 
PPTX
Number theory
Sabith Byari
 
PPSX
Aptitude trains
Sabith Byari
 
PPT
Aptitude average
Sabith Byari
 
PPT
Apti numbers
Sabith Byari
 
PPT
Time and work
Sabith Byari
 
PPSX
Aptitude Age Problems
Sabith Byari
 
Sabith_Byari-Resume_Updated
Sabith Byari
 
C your C
Sabith Byari
 
Simplification
Sabith Byari
 
Seating arr
Sabith Byari
 
Puzzles
Sabith Byari
 
Number theory
Sabith Byari
 
Aptitude trains
Sabith Byari
 
Aptitude average
Sabith Byari
 
Apti numbers
Sabith Byari
 
Time and work
Sabith Byari
 
Aptitude Age Problems
Sabith Byari
 
Ad

Recently uploaded (20)

PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 

OOPS – General Understanding in .NET

  • 2. • Introduction to OOPS • Class and Object • Encapsulation • Inheritance • Polymorphism • Interfaces • Delegate • Access Modifiers • Namespace Agenda
  • 3. About OOPS OOPS is a programming language organized around objects (data) rather than action and logic. It is composed of self sufficient modules (“Class”), each instance (“Object”) contains information to manipulate its data (“Members”) Four main features of OOPS are • Abstraction • Encapsulation • Polymorphism • Inheritance
  • 4. Object and Class • Object is an instance of a class • Object has state, behavior, and identity • Object can be created by using the NEW keyword • Communicates with other objects through message passing Object • It is a user defined data type • In OOP you program a class as a template for a specific object or groups ob objects that will always have the same features. • Other types of classes • Abstract class • Static class Class
  • 5. Encapsulation Encapsulation is the process of binding/wrapping the data and methods into a single entity Encapsulation is realized through the classes. Encapsulation guarantees the integrity of the data in the object Three main parts of Object • Interface • Implementation or Behavior • Member or Instance variables
  • 6. Access modifiers are used to implement encapsulation It reduces system complexity and thus increases robustness, by limiting the interdependencies Abstraction is achieved through encapsulation Object and Properties are examples for encapsulation
  • 7. Inheritance Inheritance is a way to form new CLASSES using classes that have already been. Inheritance is employed to help REUSE existing code with little or no modification. The new classes, known as Sub-classes (or derived classes), inherit attributes and behavior of the pre-existing classes, which are referred to as Super-classes (or ancestor classes). The inheritance relationship of SUB and SUPER CLASSES gives rise to a HIERARCHY.
  • 8. Inheritance Purpose • Reuse, extend, and modify the behavior defined in other classes • Allows to build a hierarchy of related classes Only single inheritance is allowed in .NET Three types of inheritance • Implementation • Interface • Visual To avoid inheritance, we need to use ‘sealed’ keyword
  • 9. Polymorphism Many forms of a single object is called Polymorphism. Polymorphism is important not only to the derived classes, but to the base classes as well. It allows you to invoke methods of derived class through base class reference during runtime. It has the ability for classes to provide different implementations of methods that are called through the same name.
  • 10. Polymorphism Contd… Polymorphism is of two types: • Compile time polymorphism/Overloading • Runtime polymorphism/Overriding Compile Time Polymorphism • Compile time polymorphism is method and operators overloading. It is also called early binding. • In method overloading method performs the different task at the different input parameters.
  • 11. Polymorphism Contd… • Runtime time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also called late binding. • When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same prototype. When and why to use method overloading ? Runtime Time Polymorphism
  • 12. Function Overloading Using same name for two or more functions Functions should differ with the function signature Function signature is 1.Number of parameters 2.Different data types of parameters 3.Sequence of parameters Return type is NOT part of function signature
  • 13. Operator overloading Using • Static member functions using the operator keyword Syntax • <access modifier> <Class Name> operator <operator symbol> (parameter list) • { • .Do something • } Few types of operator overloading • Unary operator overloading • Binary operator overloading
  • 14. Abstract class Purpose of an abstract class is to provide a common definition of a base class An abstract class cannot be instantiated Abstract classes may also define abstract methods Use abstract keyword Abstract methods have no implementation Use override keyword to implement abstract methods
  • 15. Virtual members Virtual members enable derived classes to extend a base class Base class member should use virtual and derived class member should use override Fields cannot be virtual
  • 16. Override virtual members in the base class Inherit base class method without overriding it Define new non-virtual implementation that hide the base class implementations The derived class can choose whether to
  • 17. Interfaces Interfaces describe a group of related functionalities Interfaces are defined by using the INTERFACE keyword Non-abstract type inheriting the interface must implement all its members Interfaces contain no implementation of methods An interface cannot be instantiated directly
  • 18. Interfaces Contd… Classes can inherit from more than one interface An interface can itself inherit from multiple interfaces Interfaces members are automatically public The member of class implementing interface member must be of the following • Public and non-static • Same name and signature
  • 19. Difference Abstract Class Interface Abstract class may contain concrete methods Interface contains methods that must be abstract Abstract class may contain non-public members. Members in an interface are public by default whereas abstract class is used to "extends". Interface is used to "implements"; Single inheritance Multiple inheritance Abstract class can "extends" another class and "implements" multiple interfaces. Interface can "extends" another interface One class can only "extends" one super class interface is more flexible than abstract class because it "implements" multiple interfaces. Any class can extend an abstract class. only an interface can extend another interface
  • 21. Delegates Contd… Multi cast delegate • Refer to multiple methods of matching signature • Derived from System.MulticastDelegate class • Example: to call two methods on a button click event Steps to use delegates • Declare a delegate with a function signature • Instantiate the declared delegate • Use the delegate to execute a function
  • 22. Access Modifiers All types and type members have an accessibility level which controls whether they can be used from other code in your assembly or other assemblies. Access modifiers are determined by the scope of visibility for variables and methods. Used to implement encapsulation and abstraction
  • 23. Access Modifiers Types of access modifiers • private • public • protected • internal • internal protected Default access modifier for class is internal Default access modifier for data member is private
  • 24. Namespace The namespace keyword is used to declare a scope. This namespace scope lets you organize code and gives you a way to create globally unique types. Within a namespace, you can declare one or more of the following types: 1.another namespace 2.class 3.interface 4.struct 5.enum 6.Delegate
  • 25. namespace Name1 { class A {} } namespace Name2 { class A {} } We can also use nested namespace namespace csharp_example { // Program start class class NamespaceCE { // Main begins program execution. public static void Main() { // Write to console Console.WriteLine("This is the new C# Example Namespace."); } } } Namespace Example