You are on page 1of 7

Module Module1

Public Class overloading


Public Function ar(ByVal r As Integer) As Double
Return 3.14 * r * r
End Function
Public Overloads Function area(ByVal l As Integer, ByVal b As
Integer) As Double
Return l * b
End Function
End Class
Sub Main()
Dim radius, length, breadth As Integer
Dim a_circle, a_rectangle As Double
Dim obj As New overloading
Console.WriteLine("****** AREA OF CIRCLE ******")
Console.WriteLine("Enter the Value of Radius of Circle : ")
radius = Console.ReadLine
a_circle = obj.ar(radius)
Console.WriteLine("AREA OF CIRCLE = {0}", a_circle)
Console.WriteLine()
Console.WriteLine()
Console.WriteLine("****** AREA OF RECTANGLE ******")
Console.WriteLine("Enter the Value of Length and Breadth of Rect: ")
length = Console.ReadLine
breadth = Console.ReadLine
a_rectangle = obj.area(length, breadth)
Console.WriteLine("AREA OF RECTANGLE = {0}", a_rectangle)
Console.ReadLine()
End Sub
End Module
Output:
Module Module1
Class person
Dim name As String
Dim city As String
Public Function get_person()
Console.Write("Enter a Name of a Person : ")
name = Console.ReadLine
Console.Write("Enter a City of a Person : ")
city = Console.ReadLine
Return 0
End Function
Public Function show_person()
Console.WriteLine("****** Details ******")
Console.WriteLine("Name of a Person = {0}", name)
Console.WriteLine("City of a Person = {0}", city)
Return 0
End Function
End Class
Class Employee
Inherits person
Dim sal As Double
Public Function get_emp()
Console.Write("Enter a Salary of a Employee : ")
sal = Console.ReadLine
Return 0
End Function
Public Function show_emp()
Console.WriteLine("Salary of a Employee = {0}", sal)
Return 0
End Function
End Class
Sub main()
Dim e1 As Employee = New Employee()
e1.get_person()
e1.get_emp()
e1.show_person()
e1.show_emp()
Console.ReadLine()
End Sub
End Module
Output:
Module module1
Dim str1 As String
Dim str2 As String
Dim str3 As String
Class original
Public Function a_string()
Console.WriteLine("Enter the Strings: ")
Console.WriteLine("First String: ")
str1 = Console.ReadLine
Return 0
End Function
End Class
Class concat
Inherits original
Public Function b_string()
Console.WriteLine("Second Strings: ")
str2 = Console.ReadLine
str3 = str1 + str2
Console.WriteLine("The Concatinate String is = {0}", str3)
Return 0
End Function
End Class
Sub main()
Dim a As concat = New concat
a.a_string()
a.b_string()
Console.ReadLine()
End Sub
End Module
Output:
Module module1
Sub division(ByVal num1 As Integer, ByVal num2 As Integer)
Dim result As Integer
Try
result = num1 \ num2
Catch ex As DivideByZeroException
Console.WriteLine("Exception Caught: {0}", ex)
Finally
Console.WriteLine("Result: {0}", result)
End Try
End Sub
Sub main()
division(25, 0)
Console.ReadKey()
End Sub
End Module
Output:
Public Class Form1
Public Class fees
Inherits ApplicationException
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim fees As Integer = TextBox1.Text
Try
If fees < 500 Then
Throw (New fees("Please pay Remaining Fees"))
Else
MsgBox("Your fees is paid upto " + TextBox1.Text)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Output:
//Department
package myinstitute;
public class dep{
public void display(){
System.out.println("Staff Name");
System.out.println("SS");
System.out.println("PC");
System.out.println("ZS");
System.out.println("Staff Name");
}
}
//Staff
import myinstitute.*;
class staff{
public static void main(String args[]){
department s = new department();
s.display();
}
}
Output:
//Comp
import sem4.*;
class comp{
public static void main(String args[]){
sub s= new sub();
s.display();
}
}

// Sub
package sem4;
public class sub{
public void display(){
System.out.println("JPR");
System.out.println("SEN");
System.out.println("CGR");
System.out.println("MIC");
System.out.println("DCC");
}
}
Output:

You might also like