Java Program List: Paper Code: Mca 3.6 Subject Name: Programming Laboratory-Iii

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

JAVA PROGRAM LIST

PAPER CODE: MCA 3.6


SUBJECT NAME: PROGRAMMING LABORATORY -III

1. Write a Menu Driven Program in Java which accepts the marks of 3 students into a 1- Dimensional array and
print total marks and percentage for each of the student
2. Write a Menu Driven Program in Java which performs sorting of a group of integer values using bubble sort
method
3. Write a Menu Driven Program in Java to perform addition of two n x n matrices
4. Write a Menu Driven Program in Java to perform multiplication of two matrices
5. Write a Menu Driven Program in Java in which take a 3-Demensional array which consists of department
wise student marks. There are 3 departments and in each department, there are 2 students and each student
has marks in 3 subjects. Calculate total marks of each student
6. Write a class called “Student” with
a) Instance variable roll_no, name, semester and branch
b) A method called “setdata ()”which takes 4 parameters and returns void. This method must contain
statements to set the values of instance variables of each object of ”Student” class
c) A method called “calculate ()” which does not have any input parameter and returns a double value.
This method must contain statements to take input for marks of 5 subjects (Physics, Chemistry,
Mathematics, English and Hindi) and calculate the percentage of marks using formula:
Percentage marks=(Total marks/500)*100
The method must also contain a return statement to return the calculated percentage value
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of roll no, name, semester, branch and percentage of
mark of each object of “Student” class
Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Student” class and display the values of their instance variable with
the calculated percentage of marks for each of them using Menu
7. Write a class called “Employee” with
a) Instance variables Employee code, Employee name and Basic salary.
b) A method called “setdata ()” which takes 3 parameters and returns void. This method must contain
statements to set the values of instance variable of each object of “Employee” class
c) A method called “calculate ()” which does not have input parameter and it returns a double value.
This method contain statements to calculate the gross salary of an Employee object using the formula
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
This method must contain a return statement to return the calculated value of Gross salary
d) A method called “showdata ()” which does not take any parameter and return void. This method must
contain statements to display the values of instance variables and calculated gross salary of each
object of “Employee” class
Write another class “EmployeeRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Employee” class and display the values of their instance variable
with the calculated gross salary for each of them using Menu
8. Write a class called “Student” with
a) Instance variable roll_no, name, semester and branch
b) A default constructor “Student ()” which must contain statements to set the values of instance
variables of each object of “Student” class from keyboard
c) A method called “calculate ()” which does not have any input parameter and returns a double value.
This method must contain statements to take input for marks of 5 subjects (Physics, Chemistry,
Mathematics, English and Hindi) from the keyboard and statements to calculate the percentage of
marks obtained by each Student object using formula:
Percentage marks=(Total marks/500)*100
The method must also contain a return statement to return the calculated percentage value
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of roll no, name, semester, branch and percentage of

Page 1 of 11
mark of each object of “Student” class
Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Student” class and display the values of their instance variable with
the calculated percentage of marks for each of them using Menu
9. Write a class called “Employee” with
a) Instance variables Employee code, Employee name and Basic salary.
b) A parameterized constructor which contains statements to set the values of instance variables of each
object of “Employee” class
c) A method called “calculate ()” which does not have input parameter and it returns a double value.
This method contain statements to calculate the gross salary of an Employee object using the formula
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
This method must contain a return statement to return the calculated value of Gross salary
d) A method called “showdata ()” which does not take any parameter and return void. This method must
contain statements to display the values of instance variables and calculated gross salary of each
object of “Employee” class

Write another class “EmployeeRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Employee” class and display the values of their instance variable
with the calculated gross salary for each of them using Menu

10. Write a class called “Rectangle” with


a) Instance variables length and breadth
b) A method called “setdata ()” which takes two parameters and returns void. This method must contain
statements to set values of instance variables of each object of “Rectangle” class.
c) A method called “calculate_area ()” which does not have any input parameter and it returns void. This
method must contain statements to calculate the area of rectangle and also statements to display the
calculated area for each of “Rectangle” class
d) A method called “showdata()” which does not take any parameter and returns void. This method
must contain statements to display the values of instance variables and calculated area for each object
of “Rectangle” class
Write another class “RectangleArea” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Rectangle” class and display the values of their instance variable
with the calculated area using Menu

11. Write a class called “Worker” with


a) Instance variable code, name, basic salary
b) A method called “setdata ()” which contains statements to set values of the instance variables of each
object of “Worker” class. Define “setdata ()” using method overloading(create as many overloaded
versions as you can)
c) A method called “calculate ()” which does not have any input parameter and it returns a double value.
This method contain statements to calculate the gross salary of an Employee object using the formula
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
This method must contain a return statement to return the calculated value of Gross salary
d) A method called “showdata ()” which does not take any parameter and return void. This method must
contain statements to display the values of instance variables and calculated gross salary of each
object of “Employee” class
Write another class “EmployeeRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Workers” class and display the values of their instance variable
with the calculated gross salary for each of them with the help of a Menu

12. Write a menu driven program in Java to calculate average of 3 variables using constructor overloading(Create
as many overloaded version as possible)

Page 2 of 11
13. Write a class called “Student” with
a) Instance variable roll_no, name, semester and branch

b) An overloaded constructor(create as many overloaded version as possible)

c) A method called “calculate ()” which does not have any input parameter and returns a double value.
This method must contain statements to take input for marks of 5 subjects (Physics, Chemistry,
Mathematics, English and Hindi) from the keyboard and statements to calculate the percentage of
marks obtained by each Student object using formula:

Percentage marks=(Total marks/500)*100


The method must also contain a return statement to return the calculated percentage value
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of roll no, name, semester, branch and percentage of
mark of each object of “Student” class

Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Student” class and display the values of their instance variable with
the calculated percentage of marks for each of them using Menu
14. Write a class called “Student” with
a) Instance variable roll_no, name, semester, branch and total marks

b) A method called “setdata ()” which takes 5 input parameters and return void. This method must
contain statements to set the values of instance variables of each object of “Student” class

c) A method called “calculate ()” which takes an object of “Student” class as parameter and it returns
void. This method must contain statements to calculate the percentage of marks of each object of
“Student ” class using formula:

Percentage marks=(total marks/500)*100


The method must also contain a return statement to return the calculated percentage value
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of instance variables together with the calculated
percentage of mark of each object of “Student” class

Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create and display 3 different object of “Student” class using Menu
15. Write a class called “Employee” with
a) Instance variables Employee code, Employee name, Basic salary and Experience.

b) A method called “setdata ()” which takes 4 parameters and return void. This method must contain
statements to set the values of instance variables of each object of “Employee” class

c) A method called “calculate ()” which takes an Employee object as parameter and returns an Employee
object as a returned value. This method contain statements to calculate the gross salary of an
Employee object using the following condition:

If Experience > 2 years then salary is incremented with an amount Rs. 2000
Otherwise no increment is given
This method must also contain a return statement to return the Employee object, taken as parameter,
after the calculation of salary is done
d) A method called “showdata ()” which does not take any parameter and return void. This method must
contain statements to display the values of instance variables of each object of “Employee” class.

Write another class “EmployeeRecord” which contains the main () method. Inside the main() method write
statements to create and display 3 different object of “Employee” class with the help of a menu.
Page 3 of 11
16. Write a class called “Student” with
a) Instance variable roll_no, name, semester, branch and total marks

b) A method called “setdata ()” which takes 5 input parameters and return void. This method must
contain statements to set the values of instance variables of each object of “Student” class

c) A method called “calculate ()” which takes an object of “Student” class as parameter and returns that
object as a returned value. This method must contain statements to calculate the percentage of marks
of each object of “Student ” class using formula:

Percentage marks=(total marks/500)*100


The method must also contain a return statement to return the inputted Student object that was
taken as parameter after the calculation of percentage for the object is done
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of instance variables of a “Student” object together with
the division obtained by student, determined using the following condition:

First Division if percentage >= 60


Second Division if percentage >=45 and <60
Otherwise Third Division
Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Student” class and display the values of their instance variables
together with the division obtained by each of them using Menu

17. Write a class called “Bank” with


a) Instance variable customer name, Account no, Balance amount
b) A method called “setdata ()” which takes 3 parameters and returns void. This method must contain
statements to set the values of instance variables of each object of “Bank” class
c) A method called “copy_record ()” which takes a Bank object as an input parameter and it returns that
object
d) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statements to display the values of instance variables of each object of “Bank” class
Write another class “DuplicateRecord” which contains the main () method. Inside the main() method write
statements to create a Bank record and copy it to create a duplicate record of it

18. Write a class called “Employee” with


a) Instance variables Employee code, Employee name and Basic salary.
b) A method called “setdata ()” which takes 3 parameters and returns void. This method must contain
statements to set the values of instance variable of each object of “Employee” class
c) A method called “calculate ()” which takes an Employee object as input parameter and it returns void.
This method contain statements to calculate the gross salary of an Employee object using the formula
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
This method must contain a return statement to return the calculated value of Gross salary
d) A method called “showdata ()” which does not take any parameter and return void. This method must
contain statements to display the values of instance variables and calculated gross salary of each
object of “Employee” class
Write another class “EmployeeRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Employee” class and display the values of their instance variable
with the calculated gross salary for each of them with the help of a Menu

Page 4 of 11
19. Write a class called “CalculateSalary” with
a) Instance variable gross salary
b) A method called “calculate ()” which does not take any parameter and returns void. This method must
contain statements to create an object of the nested class called “Employee” object of the nested class
called “Employee” with
i. Instance variable code, name, basic_salary
ii. Constructor Employee () which contains statements to take inputs from keyboard to set
values of the instance variables of each object of Employee class
iii. A method called “showdata ()” which does not take any parameter and return void. This
method must contain statements to display the values of instance variables of each object of
“Employee” class
Also this method must contain statements to display the values of the created Employee object. Also it
contain statements to calculate the gross salary of each object of “Employee” class using the formula:
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
After calculating the Gross salary the method (i.e. calculate () ) will display its value
Write another class “EmployeeRecord” which contains the main () method. Inside main() method
write statements to create 3 different objects of “Employee” class and display the values of their
instance variable with the calculated gross salary for each of them with the help of a menu
20. Write a class called “CalculatePercentage” with
a) Instance variable percentage
b) A method called “calculate ()” which does not take any parameter and returns void. This method must
contain statements to create and display an object of the nested class called “ Student” with
i. Instance variables roll_no, name, branch, semester and total marks
ii. A constructor Student () which contains statements to take inputs from keyboard to set values
of the instance variables of each object of student class
iii. A method called “showdata()” which does not take any parameter and returns void. This
method must contain statements to display the values of instance variables of each object of
the Student class
Also this method must contain statements to calculate and display the percentage of marks of each
object of student class using formula
Percentage of marks = (Total marks/500)*100
Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create 3 different object of “Student” class and display the values of their instance variables
together with the calculated percentage of marks for each of them with the help of a Menu
21. Write a Menu-Driven program in Java to swap two integer values using call-by-value method
22. Write a Menu-Driven program in Java to swap two integer values using call-by-reference method
23. Write a class called “BankAccount” with instance variables
a) Account No declared with “private” access specifier
b) Customer name declared with “public” access specifier
c) Salary declared with “default’ access specifier

24. Write a menu-Driven program in Java to calculate Factorial of a number using recursion
25. Write a class called “Student” with
a) Instance variable roll_no, name, semester and branch. roll_no will be assigned by static variable
b) A method called “setdata ()”which does not take any parameters and returns void. This method must
contain statements to take inputs from keyboard to set the values of instance variables of each object
of ”Student” class
c) A method called “showdata ()” which does not take any parameter and returns void. This method
must contain statement to display the values of instance variables of each object of “Student” class
Write another class “StudentRecord” which contains the main () method. Inside the main() method write
statements to create and display 3 different object of “Student” class using Menu

Page 5 of 11
26. Write a program in Java that compiles and runs without main() method and without any error
27. Write a class called “Circle” with
a) Instance variable radius declared ‘final’
b) A method called “setdata ()” which takes a parameter and returns void
c) A method called “area ()” which does not take any parameter and returns void
Now write another class called “AreaCircle” which contains main() method. Inside the main() method write
statements to create 3 objects of Circle class and display area for each of them using Menu
28. Write a program in Java to accept a person’s name and age through command line arguments and Display if
he is young, middle-aged or old
29. Write a program in Java to overload a vararg method to perform the following
a) Calculate area of a circle (Take radius of “double” type)
b) Calculate area of a rectangle (Take length and breadth both of “integer” type)
c) Display the name of 3 different countries
30. Write a class called “Worker” with
a) Instance variable code, name, Basic salary
b) A method called “setdata ()” which takes 3 parameters and returns void. This method must contain
statements to take inputs from the keyboard to set values of instance variables of each object of
“Worker” class
c) A method called “showdata ()” which takes no parameter and return void. This method must contain
statements to display the values of instance variables of each object of “Worker” class
Write another class “Officer” which inherits the “Worker” class with
a) Instance variable gross_ salary
b) A method called “calculate ()” which does not take input parameter and return void. This method
must contain statements to calculate the gross salary of each object of Officer class using the following
formula:
HRA= 60% of Basic salary
DA= 98% Basic salary
Gross Salary= Basic Salary + HRA + DA
Assume every worker is given a salary eual to the amount of Basic salary without any HRA or DA
Write another class “WorkerRecord” which contains the main () method. Inside the main() method write
statements to create and display one Worker and one Officer record using Menu

31. Write a class called “Student” with


a) Instance variable roll_no, name, marks for two compulsory subjects English and Hindi
b) A constructor “Student ()” which contains statements to take inputs from keyboard to set values of
instance variables of each object of “Student” class
c) A method called “show-stud ()” which does not take any input parameter and returns void. This
method must contain statement to display the values of instance variables of each object of Student
class.
Write another class “Science” which inherits Student class with
i. Instance variable : marks for two science subjects Physics and Chemistry
ii. A constructor “Science ()” which contains statements to take inputs from keyboard to set
values of instance variables of each object of Science class
iii. A method called “show-sc-stud ()” which does not contain any parameter and returns void.
This method must contain statements to display the values of instance variables of each object
of “Science” class
Write another class “ScienceStudent” which contains the main () method. Inside the main() method write
statements to create and display 3 Science students’ records using Menu

32. Write a class called “Worker” with


a) Instance variable code, name, Basic salary
b) A constructor “Worker ()”which contains statements to take inputs from keyboard to set values of
instance variables of each object of “Worker” class
c) A method called “showdata ()” which does not takes any parameter and returns void. This method
contains statements to display the values of instance variables of each object of “Worker” class
Page 6 of 11
Write a subclass “Officer”of “Worker” class with
a) Instance variable DA
b) A constructor “Officer ()” which contains statements to take inputs from keyboard to set values of
instance variables of each object of “Officer” class
c) A method “show_DA ()” which does not contain any input parameter and returns void. This method
contains statements to calculate and display DA of each Officer object using formula:
DA=98% of Basic salary
Write a subclass “Manager” of “Officer” class with
i. Instance variable HRA
ii. A constructor “Manager ()” which contains statements to take inputs from keyboard to set
values of instance variable of each object of “Manager” class
iii. A method “show-HRA ()” which does not contain any input parameter and returns void. This
method must contain statements to calculate and display HRA of each object of Manager class
using formula:
HRA = 60% of Basic salary
iv. A method called “cal_gross()” which does not take any input parameter and returns void. This
method must contain statements to calculate and display the gross amount of salary for each
object of Manager class
Now write another class called “SalaryRecord” which contains main () method. Inside the main () method
write statements to create and display 3 different salary records of 3 different Managers

33. Write a class called “Student” with


a) Instance variable roll_no, name, marks for two compulsory subjects English and Hindi
b) A constructor “Student ()” which contains statements to take inputs from keyboard to set values of
instance variables of each object of “Student” class
c) A method “show_stud ()” which does not take any input parameters and returns void. This method
must contain statements to display the values of instance variable of each object of “Student” class
Write a subclass “Science” for Science student with
i. Instance variable for the marks of two science subjects Physics and Chemistry
ii. A constructor “Science ()” which takes statements to take inputs from keyboard to set values
of instance variables of each object of Science class
iii. A method “show_science ()” which does not take any parameter and returns void. This
method must contain statements to display values of instance variables of each object of
“Science” class
Now write a subclass “Result” of “Science” class with
a) Instance variable total, percentage
b) A constructor “Result ()” to calculate total marks and percentage of each object of “Science”
class with formula:
Total = English + Hindi + Physics + Chemistry
Percentage= (total/400)* 100
c) A method called “show-result ()” which does not take any parameter and returns void. This
method must contain statements to display the values of instance variables of each object of
“”Result” class
Now write another class “ScienceResult” which contains the main () method. Inside the main () method write
statements to create and display 3 different Science students’ result record

34. Write a class called “Worker” with


a) Instance variable code, name, Basic salary
b) A constructor “Worker ()”which contains statements to take inputs from keyboard to set values of
instance variables of each object of “Worker” class
c) A method called “showdata ()” which does not takes any parameter and returns void. This method
must contains statements to display the values of instance variables of each object of “Worker” class
d) A method called “calculate_salary ()” to calculate and display the salary of each object of Worker. This
method does not take any parameter and returns void
Assume that every worker is given a salary equal to the amount of Basic Salary without any DA and
HRA
Write a subclass “Officer”of “Worker” class with
Page 7 of 11
a) Instance variable Gross salary to override the method “calculate_salary ()” to calculate gross salary
using formula:
HRA= 60% of Basic Salary
DA=98% of Basic Salary
for each object of “Officer” class
Now write another class “SalaryRecord” which contains main () method. Inside the main () method write
statements to create and display one worker and one officer record of salary
35. Write a class called “Student” with
a) Instance variable roll_no, name, English and Hindi(English and Hindi are two variables to store marks
of two compulsory subjects English and Hindi)
b) A method called setdata () which does take any input parameter and returns void. This method
contains statements to display marks of English and Hindi for each object of “Student” class
c) A method “show_sub_marks ()” which does not take any input parameters and returns void. This
method contain statements to display the values of roll_no and name of each object of “Student” class
Write two subclasses “Science” and “Arts” of “Student” class to override the method “show_sub_marks ()”
to display marks in Science and Arts subjects respectively
Now write another class “ScienceMarks” which contains the main () method. Inside the main () method write
statements to create and display one Science and one Arts students’ record using Menu
36. Write an abstract class called “Employee” with
a) Instance variables code, name, basic salary
b) A method called “setdata ()” which does not take any input parameter and returns void. This method
must contains statements to set values of instance variables of each object of Employee class from
keyboard
c) A method called “showdata ()” which does not take any input parameter and returns void. This
method must contain statements to display the values of instance variables of each object of
“Employee” class
d) An ‘abstract method’ “calculate_gross ()” which does not take any input parameter and returns void
Write a subclass “Officer” to inherit the ‘abstract class’ “Employee” to implement the abstract method
“calculate_gross ()” with the following formula :
HRA=60% of Basic salary
DA=98% of Basic salary
Gross salary = Basic salary + HRA + DA
Now write another class “SalaryRecord” which contains the main () method. Inside the main () method write
statements to create 3 different Officer objects and display gross salary for each of them using Menu

37. Write an interface called “Stud_record” with


a) A method “set_stud ()” which does not take any parameter and returns void
b) A method “show_stud ()” which does not take parameter and returns void
Write another interface called “Science_record” to inherit the interface “Stud_record” with
a) A method “set_science ()” which does not take any parameter and returns void
b) A method “show_science ()” which does not take any parameter and returns void
Write a class “Student” with instance variable
a) roll_no, name, marks of English and Hindi i.e. the two compulsory subjects
b) marks for Physics and Chemistry i.e. the two Science subjects to implement the interface
“science_record”, Student class uses “set_stud()” and “show_stud()” methods to interface
“Stud_record” to set and show roll_no, name and marks for English and Hindi. And it uses
“set_science()” and “show_science ()” methods to set and show marks for Physics and Chemistry
Now write another class “StudentRecord” which contains main () method. Write statements to create and
display records of three Science students

38. Write an interface called “DataRecord” with


a) a method void setdata(int x, String y,int z)
b) another method void showdata()
Write a class called “Student” with instance variables code, name and work_experience to implement the
interface “DataRecord”
Write another class “Record” which contains main () method. Inside the main () method write statements
to create and display one student and one employee record
Page 8 of 11
39. Write a class called “Worker” with
a) instance variables code, name, basic salary
b) A method called “setdata ()” which takes 3 parameters and returns void. This method must contain
statements to display values of instance variables of each objects of Worker class
Write a subclass of Worker class called “Officer” with
a) Instance variable HRA, DA
b) A method called “calculate ()” which does not take any input parameter and returns void. This
method must contain statements to calculate HRA and DA for each object of “Officer” class using
formula:
HRA=60% of Basic salary
DA=98% of Basic salary
c) A method called “displaydata()” which does not contain any parameter and returns void. This method
must contain statements to display HRA and DA calculated value for each object of “Officer” class
Now write an interface called “Allowance” with
a) A method called “setallowance()” which does not take any parameter and returns void
Now write class called “Manager” which inherits “Officer” class and implements interface “Allowance” with
a) Instance variable gross salary
b) The method “setallowance ()” which contains statements to calculate the gross amount of salary with
HRA and DA using formula:
Gross salary=Basic salary + HRA + DA
c) A method called “display ()” which does not take any parameter and returns void. This method must
contain statements to display the calculated gross value of salary for each Manager object
Now write another class “SalaryRecord” which contain main () method. Inside the main () method, write
statements to create three different Manager objects and display salary record for each of them using Menu

40. Write a class called “Worker” with


a) Instance variable code, name, basic salary
b) A method called “setdata ()”which does not take any parameter and returns void. This method must
contain statements to take inputs from keyboard and set values to the instance variables of each
object of the worker class
c) A method called “show-data ()”which does not take any parameter and returns void. This method
must contain statements to display values of instance variable of each object of “Worker” class
d) A method interface “calculate” with a method called “calculate-gross ()” which does not contain any
parameter and returns void
Now write a class called “Officer” which inherits the class “Worker” and implements the interface “calculate”
with
i. Instance variable gross salary and
ii. The method contains statements to calculate gross salary of each object of Officer class using formula:
HRA = 60% of Basic salary
DA=98% of Basic salary
Gross salary= Basic salary + HRA + DA
Also this method contains statements to display the calculated gross amount of salary
Now write another class “SalaryRecord” which contains the main () method. Inside the main () method write
statements to create three different objects of “Officer” class and display salary records of each of them using
Menu.

41. Create a package “rect” to store a class called “Rectangle” with


a) Instance variable length, breadth
b) A constructor with two parameters which contains statements to take inputs from thd keyboard and
set values to the instance variables of each object of Rectangle class.
c) A method called “show-data ()” which does not take any parameter and returns void. This method
contains statements to display the values of instance variables of each object of Rectangle class
Now write a program in Java to import the “rect” package to calculate area of 3 different objects of Rectangle
class using a Menu

Page 9 of 11
42. Create a package “emp” to store a class “Employee” with
a) Instance variable code, name, basic salary
b) A constructor “Employee ()” which contains statements to take inputs from keyboard to set values to
the instance variables of each object of “Employee” class
c) A method called “show-data ()” which does not take any parameter and returns void. This method
contains statements to calculate and display gross salary of store a class called “Student” with
i. Instance variables roll_no, name, total marks
ii. A constructor “Student ()”which contains statements to take inputs from keyboards to set
values to the instance variables of each object of “Student” class
iii. A method called “showdata ()” which does not contain any parameter and returns void. This
method contains statements to display values of each instance variables of the object of
“Student” class
iv. A method called “calculate ()” which does not take any parameter and returns void. This
method contains statements to calculate the percentage of marks for each object of “Student”
class using formula:
Percentage of marks=(total marks/500)*100
This method also contains statements to display the calculated values of percentage of marks
Now write a program in Java to import these two packages and create three records of each of Student and
Employee class and display each of them using Menu
43. Write an own Exception class called “MyException” and write another class called “Bank” with
a) Instance variables account_No, customer_name and balance_amount
b) A constructor called “Bank ()” which contains statements to take inputs from the keyboard and set
values of the instance variables of each object of “Bank” class
c) A method called “display ()” to display the values of instance variables of each object of “Bank” class
Now write another class called “BankRecord” which contains main () method. Inside the main () method
write statements to display a message that “A Bank File is Opened”, at the beginning. After that write
statements to create and display 3 different Bank records for 3 customers of the Bank class. After display of
the 3 records, display a message that “The Opened File is Closed”. Write all necessary codes to avoid all
possible exceptions (use all the five keywords “try”, “catch”, “throw””, “throws” and “finally”)
Take balance amount< Rs. 500 as condition to create Exception (i.e. Exception condition)
44. Write a program in Java to create a Thread and terminate the Thread by pressing the Enter button
45. Write a program in Java showing execution of multiple tasks with a single Thread
46. Write a program in Java showing two Threads working simultaneously upon object
47. Write a program in Java to synchronize two Threads acting on the same object
48. Write a program in Java to overcome a situation in which a deadlock can occur
49. Write a program in Java to create communication between two Threads in a most efficient way
50. Write a program in Java to create two Threads assigning some priority number to each and execute them on
the same object
51. Write a program in Java to create a server with two threads to communicate with several clients
52. Write a program in Java to animate a banner with a text message “Hello World” using Threads
53. Write a program in Java to perform different operations on a Stack using Menu
54. Write a program in Java to perform different operation on Linked List using Menu
55. Write a program in Java to create a one-way communication between server and client
56. Write a program in Java to create a two-way communication between server and client
57. Write a program in Java to create a generic class “Student” and display three different student records
58. Write a program in Java to design a class “Employee” that contains a generic method. Now write another class
“EmployeeRecord” (which contain main() method) to display three different Employee records using the
generic method
59. Write a program in Java to create a generic interface “Record” and a generic implementation class
“AnyRecord”. Now create another class “StoreRecord” to create and display one Employee record and one
Student record
60. Write an applet to create a form containing a Text Field for receiving the name of the user, a Text Area to
receive the address, a list box to receive the user selected items and two Push Buttons ‘OK’ and ‘Cancel’ at the
bottom of the form and again displayed in the Text area. When the Cancel button in the form is clicked, the
data typed in the form will be cleared
61. Write a Java program to pass name and salary to an Applet and get the Tax calculated

Page 10 of 11
62. Write an applet to play a .wav audio file

63. Write a program in Java to create graphical user interfaces


a) To store
b) To retrieve
a Student record using Database Oracle (use JDBC-ODBC Driver)

64. Write a program in Java to create graphical user interfaces


a) To store
b) To retrieve
an Employee record using Database MySQL (use JDBC-ODBC Driver)

65. Define a class named “Temperature”. The class has two accessors —toFahrenheit and toCelsius—that return
the temperature in the specified unit and two mutators —setFahrenheit and setCelsius—that assign the
temperature in the specified unit.
Now write a new class “TemperatureTest” containing the main () method. Inside the main () method write a
Menu-Driven program that inputs temperature in degrees Fahrenheit and outputs the temperature in
equivalent degrees Celsius and vice-versa

66. Write a program in Java to build a Digital Clock(using swing)

67. Write a program to create an applet with 3 Buttons ( Red, Green, Blue) and Text Box, When a particular
button is clicked the text colour of text box also changed to corresponding colour

68. Write a program of in Java that creates an editor and a menu with alignments left, right, centred to change the
alignments of texts in editor (using applet)

69. Write a program to create an applet with a List Box with colours (Red, Blue, Green) and when a particular list
is selected, the background of the applet changes to the colour selected from the List Box

70. Write a Menu-Driven program in Java to


i. To insert student record
ii. To view the students’ record
iii. To update the marks of a particular student
iv. To delete a particular record of a student
(create database table in MySQL and use JDBC-ODBC Driver )

Page 11 of 11

You might also like