0% found this document useful (0 votes)
26 views2 pages

Assignement 2 OOPs With Java

This document is an assignment for a course on Object-Oriented Programming with Java, focusing on exception handling and multithreading. It consists of ten long-answer questions that cover topics such as checked and unchecked exceptions, exception handling constructs, user-defined exceptions, and multithreading concepts. The assignment requires students to demonstrate their understanding through explanations and coding examples.

Uploaded by

kashifumar323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Assignement 2 OOPs With Java

This document is an assignment for a course on Object-Oriented Programming with Java, focusing on exception handling and multithreading. It consists of ten long-answer questions that cover topics such as checked and unchecked exceptions, exception handling constructs, user-defined exceptions, and multithreading concepts. The assignment requires students to demonstrate their understanding through explanations and coding examples.

Uploaded by

kashifumar323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

You might also like