OOP IN JAVA — POTENTIAL EXAM QUESTIONS
Complete Question Bank | Units 5–11
Total: 25 Questions
ASSESSMENT 2 QUESTIONS
Q.N Question Marks
o
1 What is string immutability in Java? Explain with examples. How does it 5
differ from StringBuffer? Why is StringBuffer mutable? Marks
2 What are the methods used for inter-thread communication? Write a Java 5
program to create two threads so that one thread prints even numbers and Marks
the other thread prints odd numbers between 100 and 200.
3 Differentiate between throw and throws keywords in Java with suitable 5
examples. Also explain the role of the finally block in exception handling. Marks
4 Define Stream. Write a Java program to copy the content from one file to 5
another file using character streams (FileReader and FileWriter). Marks
5 What is JDBC? Write a Java program to connect to a database named 6
Company and insert 5 employee records (EID, Ename, Salary, Department) Marks
into an Employee table. Also display all employee records whose
Department is "Sales".
6 Differentiate between Java AWT and Java Swing. List and explain any three 4
types of Layout Managers used in Java GUI programming. Marks
Q.N Question Marks
o
Unit 5: Exception Handling
7 What is an exception? Differentiate between Exception and Error in Java 5
with suitable examples. Marks
8 Explain the hierarchy of exceptions in Java with a neat diagram. 5
Differentiate between checked and unchecked exceptions. Marks
9 What is a multi-catch block in Java? Explain with an example. Also explain 5
nested try blocks and how exception propagation works from inner to outer Marks
block.
Q.N Question Marks
o
10 Why is exception handling important in Java? Explain the mechanism of 5
exception handling using try, catch, finally, throw, and throws keywords. Marks
Unit 6: String Handling
11 What is String in Java? How is a String created using literals and the new 5
keyword? Explain the String Constant Pool with a diagram. Marks
12 What is the difference between String and StringBuffer? Explain with 5
examples. List and explain any five String methods: length(), concat(), Marks
charAt(), substring(), indexOf().
13 Explain the following StringBuffer methods with examples: append(), 5
insert(), replace(), delete(), and reverse(). Marks
Unit 7: Threads
14 Define multithreading. Write a Java program to demonstrate inter-thread 5
communication using wait() and notify() methods. Marks
15 Define Thread. Explain the life cycle of a thread with all five states: New, 5
Runnable, Running, Blocked, and Terminated. Marks
16 What is thread synchronization? Why is it needed? Write a Java program to 5
demonstrate synchronization using a bank account deposit and withdrawal Marks
scenario.
17 What is a deadlock in Java? Explain with an example how deadlock occurs. 5
What are the best practices to prevent deadlock? Marks
18 Differentiate between creating a thread by extending Thread class and 5
implementing the Runnable interface. Write a Java program using Runnable Marks
to run three concurrent threads.
Unit 8: I/O and Streams
19 Define Stream. Write a Java program to copy the content from one file to 5
another using byte streams (FileInputStream and FileOutputStream). Marks
20 Differentiate between byte stream and character stream with a table. Write 5
a Java program to copy the content of a file to another file using streams. Marks
21 What is serialization and deserialization in Java? Write a Java program to 5
serialize and deserialize a Student object (name, age). Marks
Unit 9–11: Core Packages, GUI & JDBC
22 Define Collection Class. Explain different Wrapper classes and their 5
associated methods in Java. Marks
23 List and explain any five Swing controls with their uses. Write a Java GUI 5
Q.N Question Marks
o
program to calculate the square root of a number entered in a text field. Marks
24 What is JDBC? Write a Java program to connect to a database named 5
College and display all student information (Roll, Name, Address, Program) Marks
from a Student table.
25 Write short notes on any two of the following: a) JDBC Driver Types b) 5
Access Modifiers in Java c) Differences between JDK, JRE, and JVM. Marks