CSL203 Java Lab Cycle Programs
CSL203 Java Lab Cycle Programs
Total 100 marks which will be converted out of 30 while calculating Internal
Evaluation marks.
Half of the marks will be reduced for late completion of a program. The program will
not be evaluated if it was submitted later than 1 week from the date for submission,
without a valid reason.
** Mandatory Questions As Per Syllabus.
1) Write a Java program to calculate the area of different shapes namely circle,
rectangle, and triangle using the concept of method overloading. (2 marks)
2) Write a Java program which creates a class named 'Employee' having the
following mem bers: Name, Age, Phone number, Address, Salary. It also has a
method named 'printSalary( )' which prints the salary of the Employee. Two
classes 'Officer' and 'Man ager' inherits the 'Employee' class. The 'Officer' and
'Manager' classes have data members 'specialization' and 'department'
respectively. Now, assign name, age, phone number, ad dress and salary to an
officer and a manager by making an object of both of these classes and print the
same. (Exercise to understand inheritance). ** (3 marks)
3) Write two Java classes Employee and Engineer. Engineer should inherit from
Employee class. Employee class to have two methods display() and calcSalary().
Write a program to
display the engineer salary and to display from Employee class using a single
object in stantiation (i.e., only one object creation is allowed).
display() only prints the name of the class and does not return any value. Ex. “
Name of class is Employee.”
calcSalary() in Employee displays “Salary of employee is 10000” and
calcSalary() in Engineer displays “Salary of employee is 20000.” (3 marks)
4) Write a java program to create an abstract class named Shape that contains an
empty method named numberOfSides( ). Provide three classes named
Rectangle, Triangle and Hexagon such that each one of the classes extends the
class Shape. Each one of the classes contains only the method numberOfSides(
) that shows the number of sides in the given geometrical structures. (Exercise to
understand polymorphism). ** (3 marks)
5) Write a Java program to illustrate Interface inheritance. (2 marks)
6) Write a Java program to demonstrate the use of garbage collector. (2 marks)
1) Write a Java program that allows the user to draw lines, rectangles and ovals.
(2 marks) 2) Write a Java program for handling mouse events. (2 marks)
3) Write a Java program for handling key events using Adapter classes (general). (2
marks) 4) Write a Java Swing program to print a wave form on the output screen. (2
marks) 5) Write a Java program that works as a simple calculator. Arrange Buttons for
digits and
the + - * % operations properly. Add a text field to display the result. Handle any
possi ble exceptions like divide by zero. Use Java Swing. ** (5 marks)
6) Write a Java program that simulates a traffic light. The program lets the user select
one of three lights: red, yellow, or green. When a radio button is selected, the
light is turned on, and only one light can be on at a time. No light is on when the
program starts.** (5 marks)
7) Write a Java program to display all records from a table using Java Database
Connectiv ity (JDBC). (3 marks)
8) Write a program to accept rollno, name, CGPA of “n” students and store the data
to a database using JDBC connectivity. Display the list of students having CGPA
greater than 7. (Use MySQL / Oracle database). (3 marks)