0% found this document useful (0 votes)
67 views

Oops in VB

This document discusses object-oriented programming concepts in Visual Basic .NET, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It provides definitions and examples of each concept, explaining how they are implemented and their advantages for programming. Key points covered include VB.NET supporting all OOP features, classes grouping similar objects, polymorphism allowing different implementations of methods with the same name, and interfaces defining members without implementation.

Uploaded by

Mukesh sahani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Oops in VB

This document discusses object-oriented programming concepts in Visual Basic .NET, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. It provides definitions and examples of each concept, explaining how they are implemented and their advantages for programming. Key points covered include VB.NET supporting all OOP features, classes grouping similar objects, polymorphism allowing different implementations of methods with the same name, and interfaces defining members without implementation.

Uploaded by

Mukesh sahani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Oops in vb.

net
 Visual Basic is object-Based, which means it is
a Object-Oriented Programming Language.

 Visual Basic .Net supports all features of OOP


like
 Abstraction,
 Encapsulation,
 Polymorphism
 and Inheritance.
What is Object-Oriented
programming?
 Traditionally, programming has placed an
emphasis on logic and actions.

 Object oriented programming has taken a


completely different direction,and will place
an emphasis on objects and information.

 With object oriented programming, a problem


will be broken down into a number of units.
These units are called objects.
 The foundation of OOP is the fact that it will
place an emphasis on objects and classes.

 In Object-Oriented programming a program


is divided into object and these object can
communicate with each other through
functions.
Concepts of OOP:

 Objects
 Classes
 Data Abstraction
 Encapsulation
 Polymorphism
 Inheritance
Objects
 Object is the basic unit of object-oriented
programming.
 Objects are identified by its unique name.
 An object represents a particular instance of a

class.
 An Object is a collection of data members

and associated member functions also known


as methods.
 When a program is executed, objects interact

with each other by sending messages.


Classes
 Objects with similar properties and methods
are grouped together to form a Class.

 The actions that can be performed by objects


becomes functions of the class and is
referred to as Methods.
Data Abstraction
 Data Abstraction also represents the needed
information in the program without
presenting the details.
Encapsulation
 Data Encapsulation combines data and
functions into a single unit called Class.

 When using Data Encapsulation, data is not


accessed directly; it is only accessible
through the functions present inside the
class. Data Encapsulation enables the
important concept of data hiding possible.
Polymorphism
 Poly means many and morph means form.
Thus, polymorphism refers to being able to
use many forms of a type without regard to
the details.
 It is the characteristic of being able to assign

a different meaning specifically, to allow an


entity such as a variable, a function, or an
object to have more than one form.
Inheritance
 Inheritance is the process of forming a new class
from an existing class or base class. The base class
is also known as parent class or super class, The
new class that is formed is called derived class.

 Derived class is also known as a child class or sub


class.

 Inheritance helps in reducing the overall code size


of the program, which is an important concept in
object-oriented programming.
Advantages of Object-Oriented Programming: 

 OOPS provides a clear modular structure for


programs which makes it good for defining
abstract data types .
 OOPS makes it easy to maintain and modify

existing code as new objects can be created


with small differences to existing ones.
 OOPS provides a good framework for code

libraries where supplied software components


can be easily adapted and modified by the
programmer. This is particularly useful for
developing graphical user interfaces.
Polymorphism
 Polymorphism means many forms (ability to
take more than one form).

 In Polymorphism poly means “multiple” and


morph means “forms” so polymorphism
means many forms.
 In polymorphism we will declare methods
with same name and different parameters in
same class
or
 methods with same name and same

parameters in different classes.

 Polymorphism has ability to provide different


implementation of methods that are
implemented with same name.
 In Polymorphism we have 2 different types
they are

  -   Compile Time Polymorphism (Called as


Early Binding or Overloading or static binding)

  -   Run Time Polymorphism (Called as Late


Binding or Overriding or dynamic binding)
Compile Time Polymorphism

 Compile time polymorphism means we will declare


methods with same name but different signatures
because of this we will perform different tasks with
same method name. This compile time polymorphism
also called as early binding or method overloading.

 Method Overloading or compile time polymorphism


means same method names with different signatures
(different parameters)
Run Time Polymorphism

 Run time polymorphism also called as late


binding or method overriding or dynamic
polymorphism. Run time polymorphism or
method overriding means same method
names with same signatures.
 In this run time polymorphism or method
overriding we can override a method in base
class by creating similar function in derived
class this can be achieved by using
inheritance principle and using “overrides”
keywords.
Public class form1
private sub form1_click()
Dim x As New test
x.mul()
x.mul(2, 3)
End Sub
End Class
Public Class test
Dim a, b, c As Integer
Public Overloads Sub mul()
a = 12
b = 12
c=a*b
MessageBox.Show("the product is" & c)
End Sub
Public Overloads Sub mul(ByVal a As Integer, ByVal b As Integer)
c=a*b
MessageBox.Show("the product is" & c)
End Sub
End Class
Interfaces 

 Interfaces in VB.net  are used to define the


class members using a keyword Interface,
without actually specifying how it should be
implemented in a Class. 

 Intefaces are examples for multiple


Inheritance and are implemented in the
classes using the keyword Implements that is
used before any Dim statement in a class.
syntax
Public Interface name
……methods…
End Interface
Abstract class
 The keyword abstract can be used with both
classes and methods in VB.NET to declare
them as abstract.
 Abstract classes are classes that contain one

or more abstract methods. An abstract


method is a method that is declared, but
contains no implementation. Abstract classes
may not be instantiated, and require
subclasses to provide implementations for
the abstract methods.
 The classes, which we can't initialize, are
known as abstract classes.

 They provide only partial implementations.


But another class can inherit from an abstract
class and can create their instances.
DIFF BETWEEN AN ABSTRACT CLASS AND AN INTERFACE:

 An Abstract class doesn't provide full


abstraction but an interface does provide full
abstraction; i.e. both a declaration and a
definition is given in an abstract class but not
so in an interface.
 Using Abstract we can not achieve multiple

inheritance but using an Interface we can


achieve multiple inheritance.
 We can not declare a member field in an
Interface.
 We can not use any access modifier i.e. public

, private , protected , internal etc. because


within an interface by default everything is
public.
 An Interface member cannot be defined using

the keyword static, virtual, abstract or sealed.

You might also like