Code No.
: 22ITC02
CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY (Autonomous)
B.E. (IT, AI&DS) III Sem (Main) Examination Dec 2023 – Jan 2024
Java Programming
Time: 3 Hours Max Marks: 60
Note: Answer ALL questions from Part-A at one place in the same order and Part–B
(Internal Choice)
Part - A
(5Q X 2M = 10 Marks)
M CO BT
1 What are the differences between the primitive data types float and double in (2) 1 2
Java.
2 How does the "super" keyword work in object-oriented programming, and (2) 2 2
what is its significance?
3 How does multithreading enhance performance in Java applications. (2) 3 2
4 What are the advantages of using an ArrayList in Java, and how does it differ (2) 4 2
from a regular array?
5 How can servlets facilitate communication between a web client and a web (2) 5 2
server in Java web applications?
Part - B (50 Marks)
(5Q X 10M = 50 Marks)
M CO BT
6 (a) How can you use flow control statements to create a program that (5) 1 4
determines whether a given year is a leap year or not?
(b) What are Access Modifiers in Java, and how do they impact the (5) 1 4
visibility and accessibility of class members?
(OR)
7 (a) Differentiate between the 'static' and 'final' keywords in Java. (5) 1 4
(b) Develop a Java program to implement StringTokenizer using various (5) 1 3
constructors.
8 (a) Explain the concept of dynamic method dispatch in Java and discuss (5) 2 2
how it contributes to achieving polymorphism in object-oriented
programming.
(b) Discuss the concept of an inner classes. (5) 2 2
(OR)
9 (a) Explain the purpose and benefits of using packages in Java. Provide an (5) 2 2
example of how you would declare and use a package in a Java program.
(b) Consider a superclass Vehicle with a method startEngine() that prints (5) 2 3
"Engine started." Now, you have a subclass Car that extends Vehicle and
overrides the startEngine() method to print "Car engine started."
Your task is to complete the Car class by overriding the startEngine()
method. Demonstrate how method overriding works in this context.
Write the necessary code in the Car class to achieve the desired output
Page 1 of 2
Code No.: 22ITC02
10 (a) Explain the concept of thread synchronization, and provide an example (5) 3 4
code snippet demonstrating how you can use synchronization in a
multithreaded environment.
(b) Write a Java program to demonstrate the thread life cycle. (5) 3 2
(OR)
11 (a) Explain the concept of generics in java. (5) 3 2
(b) Explain the difference between checked and unchecked exceptions in (5) 3 2
Java. Provide examples of each and discuss when it is appropriate to use
one type over the other.
12 (a) Explain the main characteristics of a HashSet in Java and provide an (5) 4 2
example.
(b) Consider a scenario where you have a TreeSet of integers in Java named (5) 4 4
numberSet. Perform the following operations:
i) Add the numbers 5, 10, 3, 8, and 15 to the TreeSet.
ii) Remove the element 3 from the TreeSet.
iii) Check if the TreeSet contains the number 8.
iv) Retrieve and print the first element of the TreeSet.
v) Print the size of the TreeSet.
Write Java code snippets to demonstrate each of these operations on the
numberSet TreeSet.
(OR)
13 (a) Explain the various types of cursors in java. (5) 4 2
(b) Explain the concept of functional interfaces in Java 8. Provide an (5) 4 1
example of a functional interface.
14 (a) Explain the differences between Servlet Config and Servlet Context in (5) 5 4
Java servlets.
(b) Determine the role of Servlets in the context of web applications, and (5) 5 4
highlight some key differences between Servlets and traditional CGI
scripts.
(OR)
15 (a) Explain the lifecycle of a JSP page in detail. (5) 5 2
(b) Write a Java program using JDBC to connect to a database and retrieve (5) 5 4
the names of all employees from a table named employees.
*****
Page 2 of 2