際際滷

際際滷Share 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 cant
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
& Doesnt 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 cant create an object of an abstract class?
 Why we cant 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

What's hot (20)

Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
University of Madras
Total oop in c# dot net
Total oop in c# dot netTotal oop in c# dot net
Total oop in c# dot net
Muhammad Naveed
Core java Training in Chennai
Core java Training in ChennaiCore java Training in Chennai
Core java Training in Chennai
Core Mind
Object oriented programming interview questions
Object oriented programming interview questionsObject oriented programming interview questions
Object oriented programming interview questions
Keet Sugathadasa
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
Pritom Chaki
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
Abdalla Mahmoud
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examples
agni_agbc
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
Hirra Sultan
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and Interfaces
Ahmed Nobi
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
Haris Bin Zahid
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Anil Kumar
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
Swarup Kumar Boro
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part II
Ajit Nayak
Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
EPAM
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
Intro C# Book
Total oop in c# dot net
Total oop in c# dot netTotal oop in c# dot net
Total oop in c# dot net
Muhammad Naveed
Core java Training in Chennai
Core java Training in ChennaiCore java Training in Chennai
Core java Training in Chennai
Core Mind
Object oriented programming interview questions
Object oriented programming interview questionsObject oriented programming interview questions
Object oriented programming interview questions
Keet Sugathadasa
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
Pritom Chaki
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
Abdalla Mahmoud
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examples
agni_agbc
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
Hirra Sultan
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and Interfaces
Ahmed Nobi
Abstract class and Interface
Abstract class and InterfaceAbstract class and Interface
Abstract class and Interface
Haris Bin Zahid
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Anil Kumar
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
Swarup Kumar Boro
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part II
Ajit Nayak
Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
EPAM
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
Intro C# Book

Similar to Understanding class, object & interface (20)

Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developers
Sanjaya Prakash Pradhan
Object-oriented programming 3.pptx
Object-oriented programming 3.pptxObject-oriented programming 3.pptx
Object-oriented programming 3.pptx
Adikhan27
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
Class properties
Class propertiesClass properties
Class properties
Siva Priya
C# concepts
C# conceptsC# concepts
C# concepts
lexilijoseph
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
Medhat Dawoud
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
Questpond
Encapsulation
EncapsulationEncapsulation
Encapsulation
FALLEE31188
Mit4021%20 c# and .net
Mit4021%20 c# and .netMit4021%20 c# and .net
Mit4021%20 c# and .net
smumbahelp
C# program structure
C# program structureC# program structure
C# program structure
baabtra.com - No. 1 supplier of quality freshers
Oops
OopsOops
Oops
Sankar Balasubramanian
Polymorphism and interface in vb.net
Polymorphism and interface in vb.netPolymorphism and interface in vb.net
Polymorphism and interface in vb.net
KarthigaGunasekaran1
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
Raghuveer Guthikonda
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
C# interview
C# interviewC# interview
C# interview
Thomson Reuters
Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
Dr Anjan Krishnamurthy
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
nicolbiden
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
Kalpesh Satasiya
Sda 7
Sda   7Sda   7
Sda 7
AmberMughal5
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developers
Sanjaya Prakash Pradhan
Object-oriented programming 3.pptx
Object-oriented programming 3.pptxObject-oriented programming 3.pptx
Object-oriented programming 3.pptx
Adikhan27
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
Class properties
Class propertiesClass properties
Class properties
Siva Priya
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
Questpond
Encapsulation
EncapsulationEncapsulation
Encapsulation
FALLEE31188
Mit4021%20 c# and .net
Mit4021%20 c# and .netMit4021%20 c# and .net
Mit4021%20 c# and .net
smumbahelp
Polymorphism and interface in vb.net
Polymorphism and interface in vb.netPolymorphism and interface in vb.net
Polymorphism and interface in vb.net
KarthigaGunasekaran1
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
nicolbiden
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
Kalpesh Satasiya

Recently uploaded (20)

iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
LDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free DownloadLDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free Download
5ls1bnl9iv
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
SolidWorks 2025 Crack free Download updated
SolidWorks 2025 Crack  free Download updatedSolidWorks 2025 Crack  free Download updated
SolidWorks 2025 Crack free Download updated
sanasabaa73
AI-Powered Chatbots for Employee Support
AI-Powered Chatbots for Employee SupportAI-Powered Chatbots for Employee Support
AI-Powered Chatbots for Employee Support
AutomationEdge Technologies
Adobe InDesign Crack Full Version Free Download 2025
Adobe InDesign Crack  Full Version Free Download 2025Adobe InDesign Crack  Full Version Free Download 2025
Adobe InDesign Crack Full Version Free Download 2025
sannnasaba545
Lecture-11-AutomatedTesting-software.pptx
Lecture-11-AutomatedTesting-software.pptxLecture-11-AutomatedTesting-software.pptx
Lecture-11-AutomatedTesting-software.pptx
ssuser39f59e
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
Instagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo websiteInstagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo website
AxisTechnolabs
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Advance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management OdooAdvance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management Odoo
Aagam infotech
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
Cybersecurity & Innovation: The Future of Mobile App Development
Cybersecurity & Innovation: The Future of Mobile App DevelopmentCybersecurity & Innovation: The Future of Mobile App Development
Cybersecurity & Innovation: The Future of Mobile App Development
iProgrammer Solutions Private Limited
Data Storytelling for Portfolio Leaders - Webinar
Data Storytelling for Portfolio Leaders - WebinarData Storytelling for Portfolio Leaders - Webinar
Data Storytelling for Portfolio Leaders - Webinar
OnePlan Solutions
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Code or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose BothCode or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose Both
Applitools
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
LDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free DownloadLDPlayer 9.1.20 Latest Crack Free Download
LDPlayer 9.1.20 Latest Crack Free Download
5ls1bnl9iv
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
SolidWorks 2025 Crack free Download updated
SolidWorks 2025 Crack  free Download updatedSolidWorks 2025 Crack  free Download updated
SolidWorks 2025 Crack free Download updated
sanasabaa73
Adobe InDesign Crack Full Version Free Download 2025
Adobe InDesign Crack  Full Version Free Download 2025Adobe InDesign Crack  Full Version Free Download 2025
Adobe InDesign Crack Full Version Free Download 2025
sannnasaba545
Lecture-11-AutomatedTesting-software.pptx
Lecture-11-AutomatedTesting-software.pptxLecture-11-AutomatedTesting-software.pptx
Lecture-11-AutomatedTesting-software.pptx
ssuser39f59e
SE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.pptSE- Lecture 5 for software development.ppt
SE- Lecture 5 for software development.ppt
theworldimagine985
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
Instagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo websiteInstagram Feed Snippet, Instagram posts display in odoo website
Instagram Feed Snippet, Instagram posts display in odoo website
AxisTechnolabs
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Advance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management OdooAdvance Website Helpdesk Customer Support Ticket Management Odoo
Advance Website Helpdesk Customer Support Ticket Management Odoo
Aagam infotech
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
Data Storytelling for Portfolio Leaders - Webinar
Data Storytelling for Portfolio Leaders - WebinarData Storytelling for Portfolio Leaders - Webinar
Data Storytelling for Portfolio Leaders - Webinar
OnePlan Solutions
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Code or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose BothCode or No-Code Tests: Why Top Teams Choose Both
Code or No-Code Tests: Why Top Teams Choose Both
Applitools

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 cant 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 & Doesnt 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 cant create an object of an abstract class? Why we cant 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?