FORM NO.
F/ COE / 005
Rev.00 Date 20.03.2020
Page 1 of3
Answer Key Template (UG-E&T –UNIVERSITY EXAMINATION-2024-2025)
SUB. CODE: EBDS22ET2 SUB.NAME: JAVA PROGRAMMING
FUNDAMENTALS
DEGREE : B TECH BRANCH: ALL
YEAR/SEMESTER: I/I SECTIONS/COMMON TO: ALL
MAX.MARKS: 100 DURATION:3 Hrs
DATE: PORTION: 5 units
PART A( 10 x 1 = 10 marks) Answer All questions
Ans. No. Contents of the Answer * Allocation of
Marks
1. a)int arr[] = new int[5]; 1
2. c)public static void main(String[] args) ` 1
3. b)Reference Equality 1
4. c) Java 1.5 1
5. a)file.isDirectory() 1
6. b)Code compiles and crashes at runtime 1
7. c)Pauses the thread for a specific time 1
8. c)Inter-thread communication 1
9. a)Consumer 1
10. a)Used to execute static SQL queries 1
PART B (5x6=30 Marks) Answer any five
11. Write a Java program that defines a method to calculate the area of a circle.
Method Definition – 3 Marks
Parameter handling and return type – 2 Marks
Main method with result print – 1 Mark
12. Write a Java program that demonstrates encapsulation. Create a class Person with:
Class and private variables – 2 Marks
Getter and setter methods – 2 Marks
Object creation and usage – 2 Marks
13. What is the difference between == operator and .equals() method when comparing strings in Java?
Give examples.
Conceptual explanation – 2 Marks
Example using == – 2 Marks
Example using .equals() – 2 Marks
FORM NO. F/ COE / 005
Rev.00 Date 20.03.2020
Page 2 of3
14. How can you create a new file in Java? Explain with an example.
Explanation of file creation – 2 Marks
Code for try-catch – 4 Marks
15. Compare the following Java collections in terms of performance, ordering, duplicates, and null
handling: ArrayList, LinkedList, HashSet, and TreeSet.
Comparison table or paragraph format – 6 Marks
(Must include all four: performance, ordering, duplicates, null handling)
16. What is the difference between HashMap, TreeMap and LinkedHashMap? Write Java code to
show how iteration differs among them.
Conceptual difference – 3 Marks
Sample code for each map type – 3 Marks
17. Explain the basic steps involved in JDBC programming.
Steps like: Load Driver, Establish Connection, Create Statement, Execute
Query, Close Connection – 6 Marks
18. What are the key benefits of using Lambda Expressions in Java 8?
Explanation with benefits – 4 Marks
Example of Lambda usage – 2 Marks
PART C (5x12=60 Marks) Answer the Following
19. Explain the role of JDK, JRE and JVM in the Java development and execution process.
Explanation of JDK with diagram– 4 marks
Explanation of JRE with diagram – 4 marks
Explanation of JVM with diagram – 4 marks
20. Write a Java program that demonstrates the use of:
a) Arithmetic Operators
b) Relational Operators
c) Logical Operators
Program – 3 marks
Demonstration of arithmetic – 3 marks
Relational and logical usage – 6 marks
21. a) Explain the difference between StringBuilder and StringBuffer in Java in terms of:
i) Mutability
ii) Thread-safety
iii) Performance
FORM NO. F/ COE / 005
Rev.00 Date 20.03.2020
Page 3 of3
b) Why are StringBuilder and StringBuffer preferred over String in certain scenarios?
Differences (i, ii, iii) – 6 marks
Practical usage and preference – 6 marks
22. a) What is the Stream API in Java? How is it different from traditional iteration (like for-loops)?
b) Write a program using Stream API to filter even numbers from a list and collect them into a new
list.
Stream API concept – 4 marks
Difference from traditional iteration – 2 marks
Stream program – 6 marks
23. What is the purpose of the try and catch block in Java? Explain how exception handling is
performed using try and catch with a suitable example.
Explanation of try-catch – 4 marks
Syntax and handling method – 2 marks
Java example – 6 marks
24. How can you write data to a file in Java? Explain the process with a relevant example program.
Explanation of file writer – 4 marks
Code example using FileWriter/BufferedWriter – 8 marks
25. Discuss thread communication in Java. How do wait(), notify() and notifyAll() methods work?
Write a producer-consumer example using these methods.
Explanation of wait/notify/notifyAll – 4 marks
Producer-consumer problem – 8 marks
26. Write a Java program to demonstrate thread synchronization using the synchronized keyword.
Explain how synchronization prevents thread interference and data inconsistency.
Synchronization concept and benefits – 4 marks
Java program with synchronized – 8 marks
27. Explain the architecture of JDBC and describe the steps to perform CRUD operations using JDBC.
JDBC architecture diagram/steps – 6 marks
CRUD operations explanation – 6 marks
28. Compare and contrast DriverManager and DataSource in JDBC.
How do they influence data access performance and connection pooling?
Comparison of DriverManager and DataSource – 6 marks
Role in performance and pooling – 6 marks
Prepared by Reviewed by Approved by
Priyadharshini
IBM