OOPs with Java (BCS-403)
Assignment 2
Based on Unit 2 (CO2)
Branch: CSDS-B, AIDS
Date of Submission: 22-05-2025
Long Answer Type
Note: Attempt any 5 Questions.
Q1. What is an exception in Java? How does the Java Virtual Machine (JVM) react when an
exception occurs during program execution? Explain with an example.
Q2. Explain the difference between checked and unchecked exceptions in Java with examples
of each.
Q3. What is the role of the following exception handling constructs in Java? Explain each with a
short code example:
try
catch
finally
throw
throws
Q4. Write a Java program that demonstrates the use of:
try-catch-finally block
throw keyword to manually throw an exception
throws keyword in method declaration
Q5. Differentiate between In-built (predefined) and User-defined exceptions in Java. Give one
example of each.
Q6. Create a user-defined exception called InvalidAgeException. Write a Java program where a
user must enter their age, and if it is less than 18, the custom exception should be thrown with
the message “Age is below the legal limit.”
Q7. Why is it important to handle exceptions properly in a Java application? What could happen
if exceptions are not handled?
Q8. What is Multithreading? What are the ways to create multiple threads in java? Explain
about Thread Life Cycle.
Q9. Write a java program to create two threads and execute simultaneously.
Q10. What is synchronization in Java and why is it important in multithreading?. Explain with
suitable example.