SlideShare uma empresa Scribd logo
1 de 12
VB.NET:- Object oriented Programming
BCA -501
2
What is Object Oriented Programming?
 Object Oriented Programming (OOPs) is based on a real world interpretation of
programming elements.
 It is a type of programming in which programmers define not only the data elements but
also the operations that can be performed on the data elements.
 An object Is an entity consisting of data as well as actions. For example, consider a car.
It has various features that can describe it. These features could be the company name,
model name, price, mileage and so on. The movements of car such as acceleration,
slowing down could be considered as action.
 Object oriented programming uses class and object concept. It has several features and
advantages as well.
3
Features of Object Oriented Programming:
 Abstraction: The purpose of abstraction is to separate behaviour from implementation.
It involves extracting essential details of an entity or group of entities while ignoring the
unessential details. Thus, given an entity, the process of separating only the relevant
details from irrelevant details is called abstraction.
 Encapsulation: This concept is closely related to abstraction. Encapsulation is the
process of packaging information in such a manner that relevant information is visible
and other details of the object is hidden. In other words it is bundling the relevant details
of an object into a single unit.
 Data Hiding: Selective data or processes can be hidden from public view using this
feature. This is necessary to protect certain vital data in the application. Abstraction
identifies what information should be visible and what information can be made
inaccessible to users. Data hiding is the process of making information inaccessible.
 Polymorphism: It is the ability of an entity to have many forms. In OOP, this used to
refer to the capability of methods having many forms.
4
What is Class and object?
Class:
 A class is a group of different data members or objects with the same properties, processes,
events of an object, and general relationships to other member functions. Furthermore, we can
say that it is like a template or architect that tells what data and function will appear when it is
included in a class object. For example, it represents the method and variable that will work on
the object of the class.
 When you define a class, you define a blueprint for a data type. This doesn't actually define
any data, but it does define what the class name means, that is, what an object of the class will
consist of and what operations can be performed on such an object.
Objects:
 Objects are instances of a class. The methods and variables that constitute a class are called
members of the class.
 Objects are the basic run-time units of a class. Once a class is defined, we can create any
number of objects related to the class to access the defined properties and methods. For
example, the Car is the Class name, and the speed, mileage, and wheels are attributes of the
Class that can be accessed by the Object.
5
Syntax for declaring Class
 A class definition starts with the keyword Class followed by the class name; and the class
body, ended by the End Class statement.
 Following is the general form of a class definition −
[ Access_Specifier ] [ Shadows ] [ MustInherit | NotInheritable ] [ Partial ] Class ClassName
' Data Members or Variable Declaration
' Methods Name
' Statement to be executed
End Class
Where,
Access_Specifier: It defines the access levels of the class, such as Public, Private or Friend, Protected,
Protected Friend, etc. to use the method. (It is an optional parameter).
Shadows: It is an optional parameter. It represents the re-declaration of variables and hides an identical
element name or set of overloaded elements in a base class.
MustInherit: It is an optional parameter that specifies that the class can only be used as a base class, and
the object will not directly access the base class or the abstract class.
NotInheritable: It is also an optional parameter that representing the class not being used as a base class.
Partial: As the name defines, a Partial represents the partial definition of the class (optional).
Implements: It is used to specify interfaces from which the class inherits (optional).
6
Syntax for creating objects
 In the above syntax, we have created an instance (Obj_Name) for the class Class_Name. By
using the object name 'Obj_Name' to access all the data members and the method name
of Class_Name.
Dim Obj_Name As Class_Name = New Class_Name() ' Declaration of object
Obj_Name.Method_Name() ' Access a method using the object
7
Properties and Methods
 In Vb.NET data members that describe an object are called fields and properties.
 The members which describe object behaviour are called methods.
Properties:
 They are used in classes to denote read-only values, Values that once set cannot be changed
and values that can be read as well as changed.
 They may also be used to expose the value of private data of an object manner.
 They are the extension of variables.
 They do not denote storage locations but instead have accessors which specify statements
that can be executed to assign or retrieve values to or from the property.
 A set accessor in a property declaration is used to assign values and a Get accessor is used
to retrieve values of the property
8
Classification of Properties
 WriteOnly Properties
WriteOnly Properties must have a Set accessor and the Get accessor may be omitted. These
types of properties may be used when the value of the property is likely to change.
 ReadOnly Properties
ReadOnly properties must have a Get accessor, however the Set accessor should be omitted.
 ReadWrite Properties
A property that does not include either of the keywords ReadOnly or WriteOnly is said to be a
ReadWrite property. This type of property must have a Get accessor as well as a Set acessor.
9
Methods
 Methods govern the behaviour of the object.
 Methods in a class typically consists of action statements similar to a function or a procedure
10
Constructor
 A constructor is a method having the same name as the class within which it is defined. This
method executes automatically every time an object is created.
 Constructors are typically declared Public and are used for initialization purposes.
 In VB.NET, the lifetime of an object begins when it is created with the New Keyword.
 Constructors in VB.NET are written using the Sub New()…End Sub block.
 Operation such as opening a files or creating and opening database connections are placed
inside a constructors.
11
Destructor
 The lifetime of an object ends when it is destroyed or goes out of scope.
 In VB.NET, destructor are written using the Finalize method.
 Destructors are normally used for cleanup operations such as releasing of freeing of memory
that is no longer required.
 It is called by a system whenever an object is being destroyed.
 Syntax:
Overrides Protected Sub Finalize()
…
…
End Sub
12
Example of Constructor
Module Module1
Public Class person
Public name As String
Public gender As Char
Public address As String
Private age As Integer
Public Property agevalue() As String
Set(value As String)
age = value
End Set
Get
Return age
End Get
End Property
Public Sub New()
Console.WriteLine("This is a constructor")
End Sub
Sub main()
Dim student As New person()
'Dim employee As New person
student.name = "Abc"
student.gender = "M"
student.address = "yz"
student.agevalue = "18"
Console.WriteLine("Name of student :" +
student.name)
Console.WriteLine("Gender of student :" +
student.gender)
Console.WriteLine("Address of student :" +
student.address)
Console.WriteLine("Age of student :" +
student.agevalue)
Console.ReadKey()
End Sub
End Module

Mais conteúdo relacionado

Mais procurados

Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentalsjavaease
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introductionsandeep54552
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3C# Learning Classes
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaGlenn Guden
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)indiangarg
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPTkishu0005
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in pythonSantosh Verma
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in phpCPD INDIA
 
Inheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphismInheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphismJawad Khan
 

Mais procurados (20)

Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introduction
 
Oop in kotlin
Oop in kotlinOop in kotlin
Oop in kotlin
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
 
Class and object
Class and objectClass and object
Class and object
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 
Inheritance
InheritanceInheritance
Inheritance
 
OOPS in Java
OOPS in JavaOOPS in Java
OOPS in Java
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphismInheritance, friend function, virtual function, polymorphism
Inheritance, friend function, virtual function, polymorphism
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 

Semelhante a Oops

Semelhante a Oops (20)

My c++
My c++My c++
My c++
 
Oops
OopsOops
Oops
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .Net
 
Class and object
Class and objectClass and object
Class and object
 
OOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptxOOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptx
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 

Mais de Jaya Kumari

Python data type
Python data typePython data type
Python data typeJaya Kumari
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonJaya Kumari
 
Basic syntax supported by python
Basic syntax supported by pythonBasic syntax supported by python
Basic syntax supported by pythonJaya Kumari
 
Decision statements
Decision statementsDecision statements
Decision statementsJaya Kumari
 
Loop control statements
Loop control statementsLoop control statements
Loop control statementsJaya Kumari
 
Looping statements
Looping statementsLooping statements
Looping statementsJaya Kumari
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.netJaya Kumari
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NETJaya Kumari
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netJaya Kumari
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.netJaya Kumari
 
Frame class library and namespace
Frame class library and namespaceFrame class library and namespace
Frame class library and namespaceJaya Kumari
 
Introduction to .net
Introduction to .net Introduction to .net
Introduction to .net Jaya Kumari
 
Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script AdvanceJaya Kumari
 

Mais de Jaya Kumari (19)

Python data type
Python data typePython data type
Python data type
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Basic syntax supported by python
Basic syntax supported by pythonBasic syntax supported by python
Basic syntax supported by python
 
Overloading
OverloadingOverloading
Overloading
 
Decision statements
Decision statementsDecision statements
Decision statements
 
Loop control statements
Loop control statementsLoop control statements
Loop control statements
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NET
 
Keywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.netKeywords, identifiers and data type of vb.net
Keywords, identifiers and data type of vb.net
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Frame class library and namespace
Frame class library and namespaceFrame class library and namespace
Frame class library and namespace
 
Introduction to .net
Introduction to .net Introduction to .net
Introduction to .net
 
Jsp basic
Jsp basicJsp basic
Jsp basic
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Sgml and xml
Sgml and xmlSgml and xml
Sgml and xml
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
 
Html form
Html formHtml form
Html form
 
Html Concept
Html ConceptHtml Concept
Html Concept
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Oops

  • 1. VB.NET:- Object oriented Programming BCA -501
  • 2. 2 What is Object Oriented Programming?  Object Oriented Programming (OOPs) is based on a real world interpretation of programming elements.  It is a type of programming in which programmers define not only the data elements but also the operations that can be performed on the data elements.  An object Is an entity consisting of data as well as actions. For example, consider a car. It has various features that can describe it. These features could be the company name, model name, price, mileage and so on. The movements of car such as acceleration, slowing down could be considered as action.  Object oriented programming uses class and object concept. It has several features and advantages as well.
  • 3. 3 Features of Object Oriented Programming:  Abstraction: The purpose of abstraction is to separate behaviour from implementation. It involves extracting essential details of an entity or group of entities while ignoring the unessential details. Thus, given an entity, the process of separating only the relevant details from irrelevant details is called abstraction.  Encapsulation: This concept is closely related to abstraction. Encapsulation is the process of packaging information in such a manner that relevant information is visible and other details of the object is hidden. In other words it is bundling the relevant details of an object into a single unit.  Data Hiding: Selective data or processes can be hidden from public view using this feature. This is necessary to protect certain vital data in the application. Abstraction identifies what information should be visible and what information can be made inaccessible to users. Data hiding is the process of making information inaccessible.  Polymorphism: It is the ability of an entity to have many forms. In OOP, this used to refer to the capability of methods having many forms.
  • 4. 4 What is Class and object? Class:  A class is a group of different data members or objects with the same properties, processes, events of an object, and general relationships to other member functions. Furthermore, we can say that it is like a template or architect that tells what data and function will appear when it is included in a class object. For example, it represents the method and variable that will work on the object of the class.  When you define a class, you define a blueprint for a data type. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. Objects:  Objects are instances of a class. The methods and variables that constitute a class are called members of the class.  Objects are the basic run-time units of a class. Once a class is defined, we can create any number of objects related to the class to access the defined properties and methods. For example, the Car is the Class name, and the speed, mileage, and wheels are attributes of the Class that can be accessed by the Object.
  • 5. 5 Syntax for declaring Class  A class definition starts with the keyword Class followed by the class name; and the class body, ended by the End Class statement.  Following is the general form of a class definition − [ Access_Specifier ] [ Shadows ] [ MustInherit | NotInheritable ] [ Partial ] Class ClassName ' Data Members or Variable Declaration ' Methods Name ' Statement to be executed End Class Where, Access_Specifier: It defines the access levels of the class, such as Public, Private or Friend, Protected, Protected Friend, etc. to use the method. (It is an optional parameter). Shadows: It is an optional parameter. It represents the re-declaration of variables and hides an identical element name or set of overloaded elements in a base class. MustInherit: It is an optional parameter that specifies that the class can only be used as a base class, and the object will not directly access the base class or the abstract class. NotInheritable: It is also an optional parameter that representing the class not being used as a base class. Partial: As the name defines, a Partial represents the partial definition of the class (optional). Implements: It is used to specify interfaces from which the class inherits (optional).
  • 6. 6 Syntax for creating objects  In the above syntax, we have created an instance (Obj_Name) for the class Class_Name. By using the object name 'Obj_Name' to access all the data members and the method name of Class_Name. Dim Obj_Name As Class_Name = New Class_Name() ' Declaration of object Obj_Name.Method_Name() ' Access a method using the object
  • 7. 7 Properties and Methods  In Vb.NET data members that describe an object are called fields and properties.  The members which describe object behaviour are called methods. Properties:  They are used in classes to denote read-only values, Values that once set cannot be changed and values that can be read as well as changed.  They may also be used to expose the value of private data of an object manner.  They are the extension of variables.  They do not denote storage locations but instead have accessors which specify statements that can be executed to assign or retrieve values to or from the property.  A set accessor in a property declaration is used to assign values and a Get accessor is used to retrieve values of the property
  • 8. 8 Classification of Properties  WriteOnly Properties WriteOnly Properties must have a Set accessor and the Get accessor may be omitted. These types of properties may be used when the value of the property is likely to change.  ReadOnly Properties ReadOnly properties must have a Get accessor, however the Set accessor should be omitted.  ReadWrite Properties A property that does not include either of the keywords ReadOnly or WriteOnly is said to be a ReadWrite property. This type of property must have a Get accessor as well as a Set acessor.
  • 9. 9 Methods  Methods govern the behaviour of the object.  Methods in a class typically consists of action statements similar to a function or a procedure
  • 10. 10 Constructor  A constructor is a method having the same name as the class within which it is defined. This method executes automatically every time an object is created.  Constructors are typically declared Public and are used for initialization purposes.  In VB.NET, the lifetime of an object begins when it is created with the New Keyword.  Constructors in VB.NET are written using the Sub New()…End Sub block.  Operation such as opening a files or creating and opening database connections are placed inside a constructors.
  • 11. 11 Destructor  The lifetime of an object ends when it is destroyed or goes out of scope.  In VB.NET, destructor are written using the Finalize method.  Destructors are normally used for cleanup operations such as releasing of freeing of memory that is no longer required.  It is called by a system whenever an object is being destroyed.  Syntax: Overrides Protected Sub Finalize() … … End Sub
  • 12. 12 Example of Constructor Module Module1 Public Class person Public name As String Public gender As Char Public address As String Private age As Integer Public Property agevalue() As String Set(value As String) age = value End Set Get Return age End Get End Property Public Sub New() Console.WriteLine("This is a constructor") End Sub Sub main() Dim student As New person() 'Dim employee As New person student.name = "Abc" student.gender = "M" student.address = "yz" student.agevalue = "18" Console.WriteLine("Name of student :" + student.name) Console.WriteLine("Gender of student :" + student.gender) Console.WriteLine("Address of student :" + student.address) Console.WriteLine("Age of student :" + student.agevalue) Console.ReadKey() End Sub End Module