WAP to demonstrate Polymorphism in Vb.net through Method Overloading

WAP to demonstrate Polymorphism in Vb.net through Method Overloading

 Demonstratation of  Polymorphism in Vb.net through Method Overloading :

code begins :

Imports System.Console

Module Module1

 

Sub areas(ByVal side As Integer)

Dim area As Integer

area = side * side

WriteLine("Area of Square : " & area)

End Sub

Sub areas(ByVal l As Integer,ByVal b As Integer)

Dim area As Integer

area = l * b

WriteLine("Area of Rectangle : " & area)

End Sub

Sub areas(ByVal r As Double)

Dim area As Double

area = 4.13 * r * r

WriteLine("Area of Circle : " & area)

End Sub

 

 

Sub Main()

Dim l, b, ch As Integer

Dim r As Double

WriteLine("1. Area of a Square")

WriteLine("2. Area of a Rectange")

WriteLine("3. Area of a Circle")

WriteLine("Enter Your Choice : ")

ch = ReadLine()

 

Select Case ch

Case 1

Write("Enter Size of a side : ")

l = ReadLine()

areas(l)

Case 2

Write("Enter length : ")

l = ReadLine()

Write("Enter breadth : ")

b = ReadLine()

areas(l, b)

Case 3

Write("Enter radius : ")

r = ReadLine()

areas(r)

 

Case Else

WriteLine("Enter a Valid Choice")

 

End Select

 

End Sub

 

End Module

Output

WAP to demonstrate Polymorphism in Vb.net through Method Overloading

0 Like

Leave a Reply

Your email address will not be published. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>