Lab Assignment-1
Lab Assignment-1
Lab Assignment-1
1. Write a Java program to create a class Person which contains data members as
P_Name, P_City, P_Contact_Number. Write methods to accept and display two
Persons information.
2. Define a class ‘Month’ having data members: name, total_days and
total_holidays. Define appropriate methods to initialize and display the
values of these data members. Input values for two objects and determine
which month is having maximum working days.
3. Define a class Shape having overloaded member function area() to calculate and
display area of Square and Rectangle
4. Define a class ‘Salary’ which will contain data members basic, TA, DA, HRA. Write a
program using constructors which will initialize these values for object. Calculate
total salary of the employee using the method.
5. Define a class Book having instance variables: name, totalPages, coverPrice and
author_name. Initialize theses values using constructor for four objects and calculate
average pages and average cover price.
6. Write a java Program to accept ‘n’ no’s through the command line and store all the
prime no’s and perfect no’s into the different arrays and display both the arrays.
7. Define an Employee class with suitable attributes having getSalary() method, which
returns salary withdrawn by a particular employee. Write a class Manager which
extends a class Employee, override the getSalary() method, which will return salary
of manager by adding traveling allowance, house rent allowance etc.
8. Define a class ‘Student’ having data members name and roll_no. Inherit class
‘Teacher’ from it to have data members name and subject. Derive one more class
from ‘Teacher’ called ‘Info’. All three classes contain the Overridden method display
to display respective information of the object. Input the data in object using
constructors.
9. Create a class Shape which consists one final method area () and volume ().Create
three subclasses Rect, Circle and Triangle and calculate area and volume of it
.Implement following inheritance. Use constructors to initialize the objects.
10. Define an Interface Shape with abstract method area(). Write a java program to
calculate an area of Circle and Sphere.(use final keyword).
11. Write a package for Games in Java, which have two classes Indoor and Outdoor. Use
a method display () to generate the list of players for the specific games. (Use
Parameterized constructor, finalize() method and Array Of Objects)
12. Write a java program to accept the details of ‘n’ employees (EName ,Salary) from
the user, store them into the Hashtable and displays the Employee Names having
maximum Salary.
13. Write a java program to accept Employee name from the user and check whether it
is valid or not. If it is not valid then throw user defined Exception “Name is Invalid”
otherwise display it.
14. Write a java program to accept n names of cites from user and display them in
descending order.
15. Write a java program to accept list of file names through command line and delete
the files having extension “.txt”. Display the details of remaining files such as
FileName and size.
16. Design a screen in Java to handle the Mouse Events such as MOUSE_MOVED and
MOUSE_CLICK and display the position of the Mouse_Click in a TextField.
17. Write a Java program to design a screen using Awt that will take a user name and
password. If the user name and password are not same, raise an Exception with
appropriate message. User can have 3 login chances only. Use clear button to clear
the TextFields.
18. Write a Java program which will create a frame if we try to close it, it should change
it’scolor and it remains visible on the screen(Use swing).
19. Write a java program to accept the details employee (Eno, Ename ,Salary) and add it
into the JTable by clicking on the Button.(Max : 5 Records)