JAVA LAB CYCLE
1. Write a Java program that creates a class named 'Employee' having the following
members: Name, Age, Phone number, Address, and Salary. It also has a method named
'printSalary( )' which prints the salary of the Employee. Two classes 'Officer' and
'Manager' inherit the 'Employee' class. The 'Officer' and 'Manager' classes have data
members 'specialization' and 'department' respectively. Now, assign name, age, phone
number, address, and salary to an officer and a manager by making an object of both of
these classes and print the same.
2. Create a package named Shapes and define abstract class Shape inside it. The Shape class
should have an abstract method getArea(). Define two subclasses Rectangle and Circle that
extend the Shape class and implement the getArea() method. Create a class FindArea in a
different package and use the Rectangle and Circle classes to find the areas of a rectangle
and a circle.
3. Create a class called ’ student’ which contain the class ‘studinfo’(datamembers: int
regno,String name,int mark[]=new mark[3] ,int total) .Functions for this class are getdata()
and display(). Inherit this class to another class ‘studmark’ and compute total mark of the
student and display the student details.
4. Write a package to perform the mathematical operations - Addition, Subtraction,
Multiplication, Division, and Modulus. Write a menu-driven program for all these
operations and import the package for the above-said operation.
5. Create an abstract class called Figure which contains three data members: length, breadth,
and height. Include an abstract method to find the area. Figure class also contains concrete
methods to read the data members and to display them. Derive two classes Rectangle and
Triangle from Figure and override area() to find the area of a rectangle and triangle.
6. Write a multithreaded program to print odd numbers and even numbers from two different
threads with suitable delay.
7. Create an interface Department containing attributes deptName and deptHead. It has a
method showData() for printing the attributes. Create a class Hostel containing hostelname,
hostellocation and noofrooms and also have methods readData()for reading the details.
Then write another class named Student extending the Hostel class and implementing the
Department interface. This class which contains the attributes studname, regno, mark of
three subjects. Use getData() and caluculate() for reading and computing the total and
percentage mark of the students.
8. Write a Java program to read n numbers and race an exception called
NegativeException when you input a negative number.
9. Write an applet program to display National flag.
10. Write an applet program to load an image and display it.
11. Write an applet program to display a traffic light.
12. Write an applet program to draw a human face.
13. Write a Java program that implements educational hierarchy using inheritance
Office
empno:
empname:
salary:
Teaching NonTeaching
Designation Designation
constructor constructor
Display() Display()
14. Write a Java program that implements a multi-thread application that has three threads. The
first thread generates a multiplication table of 3. The second thread generates the
multiplication table of 7. The third thread gives the multiplication table of 9. Display the
output interchangeably with proper delay.
15. Create a class called Matrix which contains a 2d integer array, m & n (order of matrix) as
data members. Include the following member functions
a. To read the matrix,
b. To display the matrix,
c. Method product () to find the product of two matrices
d. Method sum () to find the sum of two matrices
e. Method transpose () to find the transpose of two matrices
16. Write a program using Swing to accept values in two textboxes and display the results of
mathematical operations in the third text box. Use four buttons add, subtract, multiply, and
divide.
17. Write a program using Swing to accept values in a textbox and display whether the number
is palindrome or not in another textbox
18. Write a swing program to accept an integer in a textbox then find the factorial of that
number and display the result in the second textbox.
19. Write a swing program to accept a value in a textbox then find the area and perimeter of a
circle and display the result in another textboxes.
20. Write a swing program to accept an integer in a textbox then reverse that number and
display the result in the second textbox
21. Write a swing program to interchange the values of two textboxes
22. Write a Java program to accept a number then check whether a given number is even or
odd and display the result in the second textbox.
23. Create a swing program to read the name and basic pay of the employee by using
appropriate labels and text box. When you press the button ta,da,hra,and total salary should
be displayed in the appropriate text fields
Given Equations: ta=10% of basic pay
Da=15% of basic pay
Hra=25% of basic pay
Totalsalary=basic pay+ta+da+hra]