java pyqs
java pyqs
2. atue oiultithreading and JDBC in a Java program. Design a svenario where multiple
LwCurrently insert records into adatabase table. Iniplement a mechanism to
l : . l .ta Icons0stencies or conllivts during simultaneous insertions. Provide code
4lejplatations lor your solution.
Roll No...3MCA.Q3 O
Code: CA15
MCA (SEM-) EXAMINATION^ - 2023
Programming with Java
Time: 3 Hours Max Marks: 60
. Write your Roll No. on the top lmmediately on receipt of the question paper.
Attempt ALL questions by selccting any TWO parts. All questions carry equal marks.
1. (a) What is an array in Java? What is the purpose of the enhanced for loop when working
with arrays? Explain with example.
(b What classes are used to handle Blg Numbers in Java? How can you perform addition
of two Blginteger objects?
Write a Java program to find the average of elements in an integer array. The size and
(C)
values to be stored in the array need to be taken as input from the user.
2. (a) What is an interface? Define an interface called Shape that contains of methods to
calculate area and perimeter of a 2D shape.
(b) What do you mean by Super Cosmlc class in Java? Explain the purpose of
CLASSPATH environment variable?
(C) Defne a class Student in Java consisting of student!D, firstName, lastName, address,
city, moblle, emall with necessary parameterized constructors and getter methods. It
also has a method to print the data members. Dermonstrate the working of the class
in the main program.
3. (a What is the purpose of StringTokenizer class? Write a program to tokenize the words
of the serntence: "Java, Matlab, R, C+t, Google G0, Visual Basic" and store it in an
Array.
(b) What are the advantages of generic programming? Implement a generic method in
Java to find and return the maximum element in an array of any type (e.g., integers,
doubles, or strings).
(C) How is exception handling done In Java? Provide an example of a try-catch block.
Also explain the difference between checked and unchecked exceptions.
4. (a Explain the diference between the List and Set interlaces in the Java Collection.
Implement a program that uses the ArrayList class to store and manipulate a list of
user names.
(b) What is the purpose of the synchronized keyword in Java? Provide an example of its
usage in a multithreaded program.
(c) Write a Java program that demonstrates the use of multithreading by creating and
running two threads concurrently.
5. (a Explatn the purpose of the JPanel class in Swing. Provide an example where it is used
to organlze components.
(b) Explain the purpose of the DriverManager and Connection nterfaces/ in JDBC.
Implemernt a program that retrieves data from a database table and displays it.
(c) Write a GUI appllcation using swing to calculate the area of a triangle whOse all the
three sldes a, b, and c are taken as input through text box. The user-interface should
have approprlate swing components.