SlideShare a Scribd company logo
O V E R L O A D I N G A N D O V E R R I D I N G
BY LECTURER SURAJ PANDEY CCT COLLEGE
What is overloading
 When two or more methods (functions) in the same Class have the same
name but different parameters is called method overloading.
 Class myClass
{
int Func(int x)
{
}
int Func(string s)
{
}
int Func(int x,string s)
{
}
}
 Here you can see the functions name are same but parameter type and
number of parameters are different.
BY LECTURER SURAJ PANDEY CCT COLLEGE
 Overloading is basically when you have more than one
method with the same name but a different number of or
different types of parameters. The application then
determines which one to call based on the parameters
used. Showing the 'Overloads' keyword is optional as
long as all of the methods either use it or don't use it.
 Overloading in visual basic.net is the method by which
a property or a method takes different forms at different
instances. It can also be termed as "Polymorphism".
BY LECTURER SURAJ PANDEY CCT COLLEGE
 'will work
 Public Sub Testing()
 'code here
 End Sub
 Public Sub Testing(ByVal Filename As String)
 'code here
 End Sub
 'this will also work
 Public Overloads Sub Testing()
 'code here
 End Sub
 Public Overloads Sub Testing(ByVal Filename As String)
 'code here
 End Sub
 'but this will not because only one method uses the Overloads keyword
 Public Sub Testing()
 'code here
 End Sub
 Public [b]Overloads[/b] Sub Testing(ByVal Filename As String)
 'code here
 End Sub
BY LECTURER SURAJ PANDEY CCT COLLEGE
BY LECTURER SURAJ PANDEY CCT COLLEGE
BY LECTURER SURAJ PANDEY CCT COLLEGE
What is method Overriding?
 When two or more methods (functions) have the
exact same method name, return type, number of
parameters, and types of parameters as the method
in the parent class is called method Overriding.
 Overriding in VB.net is method by which a
inherited property or a method is overidden to
perform a different functionality in a derived class.
The base class function is declared using a keyword
Overridable and the derived class function where the
functionality is changed contains an keyword
Overrides.
BY LECTURER SURAJ PANDEY CCT COLLEGE
 'base class
 Public Class BaseClass
 Public Overridable Sub Testing()
 Msgbox("Shown from the Base")
 End Sub
 End Class
 'derived class
 Public Class DerivedClass
 Inherits BaseClass
 Public Overrides Sub Testing()
 Msgbox("Shown from the Derived")
 End Sub
 End Class
 'then in an app
 Dim bc as New BaseClass()
 bc.Testing()
 Dim dc as New DerivedClass()
 dc.Testing()
BY LECTURER SURAJ PANDEY CCT COLLEGE
BY LECTURER SURAJ PANDEY CCT COLLEGE
BY LECTURER SURAJ PANDEY CCT COLLEGE
Difference between method overloading and method overriding
 Method overloading happens in the same class shares the
same method name but each method should have
different number of parameters or parameters having
different types and order. But in method overriding
derived class have the same method with same name and
exactly the same number and type of parameters and
same return type as a parent class.
 Method Overloading happens at compile time while
Overriding happens at runtime. In method overloading,
method call to its definition has happens at compile time
while in method overriding, method call to its definition
happens at runtime. More about..... Static binding and
dynamic binding
BY LECTURER SURAJ PANDEY CCT COLLEGE
 In method Overloading, two or more methods shares the
same name in the same class but having different
signature while in method overriding, method of parent
class is re-defined in the inherited class having same
signature.
 In the case of performance, method overloading gives
better performance when compared to overriding
because the binding of overridden methods is being done
at runtime.
 Static binding is happens when method overloaded while
dynamic binding happens when method overriding.
BY LECTURER SURAJ PANDEY CCT COLLEGE
 Method overloading add or extend more to the
method functionality while method overloading is to
change the existing functionality of the method
 Static methods can be overloaded, that means a class
can have more than one static method of same name.
But static methods cannot be overridden, even if you
declare a same static method in derived class it has
nothing to do with the same method of base class.
BY LECTURER SURAJ PANDEY CCT COLLEGE

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 

What's hot (20)

Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Inheritance
InheritanceInheritance
Inheritance
 
Java swing
Java swingJava swing
Java swing
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Event handling
Event handlingEvent handling
Event handling
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Servlets
ServletsServlets
Servlets
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Polymorphism in Python
Polymorphism in Python Polymorphism in Python
Polymorphism in Python
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 

Similar to Overloading and overriding in vb.net

chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)
It Academy
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
Terry Yoast
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
Michael Peacock
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 

Similar to Overloading and overriding in vb.net (20)

Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding  in java  hdmIntroduction to method overloading & method overriding  in java  hdm
Introduction to method overloading & method overriding in java hdm
 
Inheritance Slides
Inheritance SlidesInheritance Slides
Inheritance Slides
 
Learn java lessons_online
Learn java lessons_onlineLearn java lessons_online
Learn java lessons_online
 
Inheritance_Polymorphism_Overloading_overriding.pptx
Inheritance_Polymorphism_Overloading_overriding.pptxInheritance_Polymorphism_Overloading_overriding.pptx
Inheritance_Polymorphism_Overloading_overriding.pptx
 
overridning.ppt
overridning.pptoverridning.ppt
overridning.ppt
 
chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)chap 6 : Objects and classes (scjp/ocjp)
chap 6 : Objects and classes (scjp/ocjp)
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
 
Core java by amit
Core java by amitCore java by amit
Core java by amit
 
Chap11
Chap11Chap11
Chap11
 
polymorphism method overloading and overriding .pptx
polymorphism method overloading  and overriding .pptxpolymorphism method overloading  and overriding .pptx
polymorphism method overloading and overriding .pptx
 
Core java oop
Core java oopCore java oop
Core java oop
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)Java Polymorphism: Types And Examples (Geekster)
Java Polymorphism: Types And Examples (Geekster)
 
Unit 2 Part 1 POLYMORPHISM.pdf
Unit 2 Part 1 POLYMORPHISM.pdfUnit 2 Part 1 POLYMORPHISM.pdf
Unit 2 Part 1 POLYMORPHISM.pdf
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Basic concept of class, method , command line-argument
Basic concept of class, method , command line-argumentBasic concept of class, method , command line-argument
Basic concept of class, method , command line-argument
 

More from suraj pandey

More from suraj pandey (20)

Systemcare in computer
Systemcare in computer Systemcare in computer
Systemcare in computer
 
vb.net Constructor and destructor
vb.net Constructor and destructorvb.net Constructor and destructor
vb.net Constructor and destructor
 
Basic in Computernetwork
Basic in ComputernetworkBasic in Computernetwork
Basic in Computernetwork
 
Computer hardware
Computer hardwareComputer hardware
Computer hardware
 
Dos commands new
Dos commands new Dos commands new
Dos commands new
 
History of computer
History of computerHistory of computer
History of computer
 
Dos commands
Dos commandsDos commands
Dos commands
 
Basic of Internet&email
Basic of Internet&emailBasic of Internet&email
Basic of Internet&email
 
Basic fundamental Computer input/output Accessories
Basic fundamental Computer input/output AccessoriesBasic fundamental Computer input/output Accessories
Basic fundamental Computer input/output Accessories
 
Introduction of exception in vb.net
Introduction of exception in vb.netIntroduction of exception in vb.net
Introduction of exception in vb.net
 
Transmission mediums in computer networks
Transmission mediums in computer networksTransmission mediums in computer networks
Transmission mediums in computer networks
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Introduction to computer
Introduction to computerIntroduction to computer
Introduction to computer
 
Computer Fundamental Network topologies
Computer Fundamental Network topologiesComputer Fundamental Network topologies
Computer Fundamental Network topologies
 
Basic of Computer software
Basic of Computer softwareBasic of Computer software
Basic of Computer software
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
 
Generics in java
Generics in javaGenerics in java
Generics in java
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 

Recently uploaded (20)

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 

Overloading and overriding in vb.net

  • 1. O V E R L O A D I N G A N D O V E R R I D I N G BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 2. What is overloading  When two or more methods (functions) in the same Class have the same name but different parameters is called method overloading.  Class myClass { int Func(int x) { } int Func(string s) { } int Func(int x,string s) { } }  Here you can see the functions name are same but parameter type and number of parameters are different. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 3.  Overloading is basically when you have more than one method with the same name but a different number of or different types of parameters. The application then determines which one to call based on the parameters used. Showing the 'Overloads' keyword is optional as long as all of the methods either use it or don't use it.  Overloading in visual basic.net is the method by which a property or a method takes different forms at different instances. It can also be termed as "Polymorphism". BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 4.  'will work  Public Sub Testing()  'code here  End Sub  Public Sub Testing(ByVal Filename As String)  'code here  End Sub  'this will also work  Public Overloads Sub Testing()  'code here  End Sub  Public Overloads Sub Testing(ByVal Filename As String)  'code here  End Sub  'but this will not because only one method uses the Overloads keyword  Public Sub Testing()  'code here  End Sub  Public [b]Overloads[/b] Sub Testing(ByVal Filename As String)  'code here  End Sub BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 5. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 6. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 7. What is method Overriding?  When two or more methods (functions) have the exact same method name, return type, number of parameters, and types of parameters as the method in the parent class is called method Overriding.  Overriding in VB.net is method by which a inherited property or a method is overidden to perform a different functionality in a derived class. The base class function is declared using a keyword Overridable and the derived class function where the functionality is changed contains an keyword Overrides. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 8.  'base class  Public Class BaseClass  Public Overridable Sub Testing()  Msgbox("Shown from the Base")  End Sub  End Class  'derived class  Public Class DerivedClass  Inherits BaseClass  Public Overrides Sub Testing()  Msgbox("Shown from the Derived")  End Sub  End Class  'then in an app  Dim bc as New BaseClass()  bc.Testing()  Dim dc as New DerivedClass()  dc.Testing() BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 9. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 10. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 11. Difference between method overloading and method overriding  Method overloading happens in the same class shares the same method name but each method should have different number of parameters or parameters having different types and order. But in method overriding derived class have the same method with same name and exactly the same number and type of parameters and same return type as a parent class.  Method Overloading happens at compile time while Overriding happens at runtime. In method overloading, method call to its definition has happens at compile time while in method overriding, method call to its definition happens at runtime. More about..... Static binding and dynamic binding BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 12.  In method Overloading, two or more methods shares the same name in the same class but having different signature while in method overriding, method of parent class is re-defined in the inherited class having same signature.  In the case of performance, method overloading gives better performance when compared to overriding because the binding of overridden methods is being done at runtime.  Static binding is happens when method overloaded while dynamic binding happens when method overriding. BY LECTURER SURAJ PANDEY CCT COLLEGE
  • 13.  Method overloading add or extend more to the method functionality while method overloading is to change the existing functionality of the method  Static methods can be overloaded, that means a class can have more than one static method of same name. But static methods cannot be overridden, even if you declare a same static method in derived class it has nothing to do with the same method of base class. BY LECTURER SURAJ PANDEY CCT COLLEGE