Java Program List: Paper Code: Mca 3.6 Subject Name: Programming Laboratory-Iii
Java Program List: Paper Code: Mca 3.6 Subject Name: Programming Laboratory-Iii
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
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
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:
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:
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:
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
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
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
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
Page 11 of 11