Java Lab QB - CIE-2024
Java Lab QB - CIE-2024
Part A
1 Write a java program to display the employee details (ID, Name, Age, Salary) for
three employees. Read details using Scanner class. Display the names of
employees in the order of their age.
2 Write a java program to create an array of objects and perform matrix
multiplication on two given matrices.
3 Write a java program to implement the following
a. Create a superclass called student with data members as USN, Name and marks
b. Create a subclasses called UG_student having the fields USN, Name, and total no.
of semesters (ToS) and marks for three subjects
c. Create a subless PG_Student that extends student class which has the data
members USN, Name and Total No. of Semesters ( ToS) and marks for three
subjects
d. Define the main function to display the details for three students using arrays
of objects.
4 Write a java program to implement stack operation (Push, Pop). Your class should
have an empty constructor. Create two objects to demonstrate the stack operation
for 10 items.
5 Write a java program to maintain the student details like USN, Dept names, 3
subject grades and SGPA in student package and keep the staff details such as
Staffid, StaffName, designation and subjects handled in a staff package. In main
class use these two packages details for Staff and Student classes and display the
student and staff information as requested by the user.
Department of Artificial Intelligence and Data Science/
Department of Artificial Intelligence and Machine
Learning
6 Java program to find area of rectangle & triangle using Interface.
7 Write a Java program to demonstrate exception handling using try, multiple catch
block and finally block. Throw an error in try block to handle array out of bound
index.
8 Write java program to demonstrate swing, Display the button on UI with “click
“text on the button.
Department of Artificial Intelligence and Data Science/
Department of Artificial Intelligence and Machine
Learning
PART – B
1. Write a Java Program that does the following
a. Create a super class called Car. The Car class has the following fields and
methods.
int speed; double regularPrice; String color; double getSalePrice();
b. Create a sub class of Car class and name it as Truck. The Truck class has the
following fields and methods.
int weight; double getSalePrice();
/If weight>2000,10% discount. Otherwise,20%discount.
c. Create a subclass of Car class and name it as Ford. The Ford class has the
following fields and methods.
int year; int manufacturerDiscount; double getSalePrice();
//From the sale price computed from Carclass, subtract the manufacturer
Discount.
d. Create a subclass of Car class and name it as Sedan. The Sedan class has the
following fields and methods.
int length; double getSalePrice();
//If length>20 feet, 5% discount, Otherwise, 10% discount.
e. Create MyOwnAutoShop class which contains the main() method. Perform the
following within the main() method.
f. Create an instance of Sedan class and initialize all the fields with appropriate
values.
g. Use super(...) method in the constructor for initializing the fields of the
superclass.
e. Create an instance of the Ford class and initialize all the fields with
appropriate values
f. Use super(...) method in the constructor for initializing the fields of the super
class.
g. Create an instance of Car class and initialize all the fields with appropriatevalues.
Display the sale prices of all instances.
2 Write a Java Program that does the following related to Inheritance:
i. To calculate y = sin(x)+cos(x)+tan(x)
5 Write a java program to keep details of bank customer name and balance in
MyPack package, Initialize using contractors and define display function. In main
class use this package and pass the information (name and balance) and display
using display function.
Thread 1 will print all the prime numbers from 1 to 100. Thread will sleep for
0.5 second after printing every number.
Thread 2 will print all the numbers from 100 to 200. Thread will sleep for 0.5
second after printing every number.
Print Prime Numbers from 1 to 50 using Thread1. Print Prime Numbers from 100
to 150 using Thread2. After Every number, put the thread to sleep.