0% found this document useful (0 votes)
3 views3 pages

Java 1

The document outlines an assignment for a Java Programming course at Hindustan College of Engineering and Technology, submitted by a student named Madhubala N. It includes a program demonstrating nested try-catch blocks to handle exceptions such as division by zero and invalid array indices. The assignment was submitted on the due date of November 13, 2025, to Dr. A.R. Jayasudha, HOD of MCA.

Uploaded by

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

Java 1

The document outlines an assignment for a Java Programming course at Hindustan College of Engineering and Technology, submitted by a student named Madhubala N. It includes a program demonstrating nested try-catch blocks to handle exceptions such as division by zero and invalid array indices. The assignment was submitted on the due date of November 13, 2025, to Dr. A.R. Jayasudha, HOD of MCA.

Uploaded by

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

HINDUSTHANCOLLEGEOFENGINEERINGANDTECHNOLOGY

AnAutonomousInstitution
ApprovedbyAICTE,NewDelhi,AffiliatedtoAnnaUniversity,Chennai
AccreditedbyNBA(AERO,AUTO,BME,CIVIL,CHE,CSE,ECE,EEE,FOOD,IT,MECH,MCT,FT,AGRI,MCA,MBA)
Accreditedwith'A++'GradebyNAAC.
Coimbatore- 641032

RegisterNo 720725207038 Name of the Student Madhubala N

CourseCode &Name 24CA1203–JAVA PROGRAMMING

Regulations 2024
Branch MCA
Semester ONE
Batch 2025-2027
AssignmentNumber FIRST

SubmittedTo [Link] /HOD/MCA

Due Date 13-11-2025


SubmittedDate 13-11-2025
1. Demonstrate Nested try

Program :

import [Link];
public class NestedTryDemo {
public static void main(String[] args) {
Scanner sc = new Scanner([Link])
try {
[Link]("Enter numerator: ");
int num1 = [Link]()
[Link]("Enter denominator: ");
int num2 = [Link]();
try
{
int result = num1 / num2;
[Link]("Result = " + result);
}
catch (ArithmeticException e)
{
[Link]("Error: Division by zero is not allowed!");
}

try
{
int[] arr = {10, 20, 30};
[Link]("Enter array index: ");
int index = [Link]();
[Link]("Element = " + arr[index]);
}

catch (ArrayIndexOutOfBoundsException e)
{
[Link]("Error: Invalid array index!");
}

}
catch (Exception e)
{
[Link]("Error: Invalid input!");
}

[Link]("Program executed successfully!");


[Link]();
}
}
Output :

You might also like