You are on page 1of 5

Lab 4

Classes and Objects in java


Task 1:
Assign and print the roll number, phone number and address of two students having names
"Babar" and "Danish" respectively by creating two objects of class 'Student'.
Source code:

1
Lab 4

Output:

Task 2:

2
Lab 4

Add two distances in inch-feet by creating a class named 'AddDistance'.


Source code:

Output:

Task 3:

3
Lab 4

Create a class Employ and add information of 5 employees like name,id,address and print all
information.
Source code:

Output:

4
Lab 4

Task 4:
Print the average of three numbers entered by user by creating a class named 'Average' having
a method to calculate and print the average.
Source code:

Output:

You might also like