SlideShare a Scribd company logo
Understanding
Class, Object & Interface
Md. Shohag Mia
Software Developer (C#)
shohag-ds@outlook.com
Contents
 Introductions
 Definition of Class, Object & Interface
 Adding variable & methods into Class
 Class member access modifiers & Constructor
 Creating objects & accessing class member
 Static Member for class
 Creating & Implement interface into class
 Distinguish between Class, Object & Interface
 Questions
Introduction
Class & Object are the basic concepts of Object Oriented Programming which revolve
around the real-life entities.
In C#, classes support the polymorphism, inheritance and also provide the concept of
derived classes and base classes.
Interfaces in Object Oriented Programming Languages, An interface is a
programming structure/syntax that allows the computer to enforce certain properties
on an object (class).
Definition of Class
Class:
A class is like a blueprint of specific object. A class enables you to create your own
custom types by grouping together variables of other types, properties, behavior,
methods and events etc. Define an interface by using the class keyword.
Example- Every object has some color, shape and functionalities etc.
Syntax:
public class MyClass
{
//Here are Properties, Methods & Events
}
Definition of Object
Object:
An object is basically a block of memory that has been allocated and configured according
to the blueprint of the class. A program may create many objects of the same class.
Objects are also called instances and they can be stored in either a named variable or in an
array or collection. Define an interface by using the new keyword.
Example:
Customer, Student, Mobile Phone & Car etc.
Syntax:
BankAccount account = new BankAccount()
Definition of Interface
Interface:
An interface is like an abstract base class. Any class or struct that implements the interface must
implement all its members. An interface can't be instantiated directly. Its members are implemented by
any class or struct that implements the interface. Interfaces can contain events, indexers, methods,
and properties. Define an interface by using the interface keyword.
Interfaces in C# are a means to get around the lack of multiple inheritance in C#, meaning you can’t
inherit from multiple classes but you can implement multiple interfaces.
Example: All bank account holders can be operate cash withdrawal & deposit commonly.
Syntax:
interface IMyInterface
{
// contain events, indexers, methods, and properties here…
}
Adding variable/Properties & methods into
Class
Class member access modifiers
Creating objects & accessing class member
Static Member for a class
“static” means “relating to the type itself, rather than an instance of the type”. You access a static member using the
type name instead of a reference or a value, e.g. DateTime.Now()
In addition to methods and variables, you can also declare a class to be static (since C# 2.0). A static class cannot be
instantiated and can only contain static members.
Creating & Implement interface into class
Distinguish between Class, Object & Interface
Class Object Interface
A class describes the attributes and
behaviors (Blueprint) of an object.
An object is the instance of the class to
use variables and methods from inside the
class.
An interface contains behaviors that a
derived class implements it.
A class may contain abstract methods,
concrete methods & constructor.
A class may contain variables and
methods.
An interface contains only abstract methods
& Doesn’t contains constructor.
Members of a class can be public, private,
protected or default.
Internal is the default if no access
modifier is specified.
All the members of the interface are public
by default.
Classes have logical existence. Objects have a physical existence.
Interface have logical existence.
A class doesn't take any memory spaces
when a programmer creates one.
An object takes memory when a
programmer creates one.
A interface doesn't take any memory
spaces but only for carry on reference.
The class has to be declared only once. Objects can be declared several times
depending on the requirement.
The interface has to be declared only
once.
Demo with Class
Demo with Interface
Try to Resolve
 What is class?
 What is object?
 What is interface?
 Difference between Class & Object?
 Difference between Class & Interface?
 Why we use static keyword?
 How static member is accessed?
 What is the benefits of interface?
 Can you explain about constructor & deconstructor?
 Can you create an instance of an interface?
 Can you create an instance of an abstract class?
 Why we can’t create an object of an abstract class?
 Why we can’t specify the accessibility modifier for methods inside the interface?
 Is it possible can have multiple methods in a single class?
 Is it necessary for abstract class to have abstract method?
 When do you favor abstract class over interface?
Any questions?

More Related Content

PPTX
Interface in Java
PPT
friend function(c++)
PPTX
Friend function OOPC
PPTX
Friend function
PDF
Lecture 10
PDF
Access specifiers (Public Private Protected) C++
PPTX
Friend Function
PPTX
[OOP - Lec 07] Access Specifiers
Interface in Java
friend function(c++)
Friend function OOPC
Friend function
Lecture 10
Access specifiers (Public Private Protected) C++
Friend Function
[OOP - Lec 07] Access Specifiers

What's hot (20)

PDF
Friend function in c++
PDF
Total oop in c# dot net
PDF
Core java Training in Chennai
PDF
Object oriented programming interview questions
PPTX
Classes objects in java
PPT
Jedi slides 2.1 object-oriented concepts
PPTX
Object Orinted Programing(OOP) concepts \
PPT
Object-Oriented Concepts
PPSX
C#, OOP introduction and examples
PPTX
Constructor in java
PPTX
Inheritance in oops
PPTX
Abstraction in java [abstract classes and Interfaces
PPTX
Abstract class and Interface
PPTX
Classes and objects
PDF
Implementation of oop concept in c++
PDF
Multiple Inheritance
PDF
Object Oriented Programming using C++ Part II
PDF
Object Oriented Concepts in Real Projects
PPTX
C# classes objects
PPT
20. Object-Oriented Programming Fundamental Principles
Friend function in c++
Total oop in c# dot net
Core java Training in Chennai
Object oriented programming interview questions
Classes objects in java
Jedi slides 2.1 object-oriented concepts
Object Orinted Programing(OOP) concepts \
Object-Oriented Concepts
C#, OOP introduction and examples
Constructor in java
Inheritance in oops
Abstraction in java [abstract classes and Interfaces
Abstract class and Interface
Classes and objects
Implementation of oop concept in c++
Multiple Inheritance
Object Oriented Programming using C++ Part II
Object Oriented Concepts in Real Projects
C# classes objects
20. Object-Oriented Programming Fundamental Principles
Ad

Similar to Understanding class, object & interface (20)

PPTX
Abstraction1
PPTX
Better Understanding OOP using C#
PPTX
abstract class and interface.Net
PPT
CSharp_03_ClassesStructs_and_introduction
PPT
Using class and object java
PPT
11 Using classes and objects
PPT
Inheritance
PDF
Object-oriented programming (OOP) with Complete understanding modules
DOCX
C# concepts
PPTX
Object Oriented Principles
PPTX
Object Oriented Programming with C#
DOCX
Question and answer Programming
PDF
Web Design & Development - Session 9
PDF
Object-oriented Analysis, Design & Programming
PPTX
Introduction to oop
PPTX
Fundamentals of oops in .Net
PPTX
Quick Interview Preparation for C# All Concepts
PDF
Object Oriented Programming with C#
Abstraction1
Better Understanding OOP using C#
abstract class and interface.Net
CSharp_03_ClassesStructs_and_introduction
Using class and object java
11 Using classes and objects
Inheritance
Object-oriented programming (OOP) with Complete understanding modules
C# concepts
Object Oriented Principles
Object Oriented Programming with C#
Question and answer Programming
Web Design & Development - Session 9
Object-oriented Analysis, Design & Programming
Introduction to oop
Fundamentals of oops in .Net
Quick Interview Preparation for C# All Concepts
Object Oriented Programming with C#
Ad

Recently uploaded (20)

PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Nekopoi APK 2025 free lastest update
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
assetexplorer- product-overview - presentation
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Navsoft: AI-Powered Business Solutions & Custom Software Development
Salesforce Agentforce AI Implementation.pdf
CHAPTER 2 - PM Management and IT Context
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
wealthsignaloriginal-com-DS-text-... (1).pdf
Nekopoi APK 2025 free lastest update
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Weekly report ppt - harsh dattuprasad patel.pptx
Designing Intelligence for the Shop Floor.pdf
assetexplorer- product-overview - presentation
Adobe Illustrator 28.6 Crack My Vision of Vector Design
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Wondershare Filmora 15 Crack With Activation Key [2025
Why Generative AI is the Future of Content, Code & Creativity?
Advanced SystemCare Ultimate Crack + Portable (2025)
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf

Understanding class, object & interface

  • 1. Understanding Class, Object & Interface Md. Shohag Mia Software Developer (C#) shohag-ds@outlook.com
  • 2. Contents  Introductions  Definition of Class, Object & Interface  Adding variable & methods into Class  Class member access modifiers & Constructor  Creating objects & accessing class member  Static Member for class  Creating & Implement interface into class  Distinguish between Class, Object & Interface  Questions
  • 3. Introduction Class & Object are the basic concepts of Object Oriented Programming which revolve around the real-life entities. In C#, classes support the polymorphism, inheritance and also provide the concept of derived classes and base classes. Interfaces in Object Oriented Programming Languages, An interface is a programming structure/syntax that allows the computer to enforce certain properties on an object (class).
  • 4. Definition of Class Class: A class is like a blueprint of specific object. A class enables you to create your own custom types by grouping together variables of other types, properties, behavior, methods and events etc. Define an interface by using the class keyword. Example- Every object has some color, shape and functionalities etc. Syntax: public class MyClass { //Here are Properties, Methods & Events }
  • 5. Definition of Object Object: An object is basically a block of memory that has been allocated and configured according to the blueprint of the class. A program may create many objects of the same class. Objects are also called instances and they can be stored in either a named variable or in an array or collection. Define an interface by using the new keyword. Example: Customer, Student, Mobile Phone & Car etc. Syntax: BankAccount account = new BankAccount()
  • 6. Definition of Interface Interface: An interface is like an abstract base class. Any class or struct that implements the interface must implement all its members. An interface can't be instantiated directly. Its members are implemented by any class or struct that implements the interface. Interfaces can contain events, indexers, methods, and properties. Define an interface by using the interface keyword. Interfaces in C# are a means to get around the lack of multiple inheritance in C#, meaning you can’t inherit from multiple classes but you can implement multiple interfaces. Example: All bank account holders can be operate cash withdrawal & deposit commonly. Syntax: interface IMyInterface { // contain events, indexers, methods, and properties here… }
  • 7. Adding variable/Properties & methods into Class
  • 9. Creating objects & accessing class member
  • 10. Static Member for a class “static” means “relating to the type itself, rather than an instance of the type”. You access a static member using the type name instead of a reference or a value, e.g. DateTime.Now() In addition to methods and variables, you can also declare a class to be static (since C# 2.0). A static class cannot be instantiated and can only contain static members.
  • 11. Creating & Implement interface into class
  • 12. Distinguish between Class, Object & Interface Class Object Interface A class describes the attributes and behaviors (Blueprint) of an object. An object is the instance of the class to use variables and methods from inside the class. An interface contains behaviors that a derived class implements it. A class may contain abstract methods, concrete methods & constructor. A class may contain variables and methods. An interface contains only abstract methods & Doesn’t contains constructor. Members of a class can be public, private, protected or default. Internal is the default if no access modifier is specified. All the members of the interface are public by default. Classes have logical existence. Objects have a physical existence. Interface have logical existence. A class doesn't take any memory spaces when a programmer creates one. An object takes memory when a programmer creates one. A interface doesn't take any memory spaces but only for carry on reference. The class has to be declared only once. Objects can be declared several times depending on the requirement. The interface has to be declared only once.
  • 15. Try to Resolve  What is class?  What is object?  What is interface?  Difference between Class & Object?  Difference between Class & Interface?  Why we use static keyword?  How static member is accessed?  What is the benefits of interface?  Can you explain about constructor & deconstructor?  Can you create an instance of an interface?  Can you create an instance of an abstract class?  Why we can’t create an object of an abstract class?  Why we can’t specify the accessibility modifier for methods inside the interface?  Is it possible can have multiple methods in a single class?  Is it necessary for abstract class to have abstract method?  When do you favor abstract class over interface?