II B.Tech II Sem CSE Java Lab Exercise - 7a (Exception)

a) Exception handling mechanism

Aim: To write a JAVA program that describes exception handling mechanism


Description:


Program:

Usage of Exception Handling:

class trydemo 
{
public static void main(String args[]) 
{
try 
{
int a=10,b=0;
int c=a/b;
System.out.println(c);
}
catch(ArithmeticException e) 
{
System.out.println(e); 
}
System.out.println("After the catch statement"); 
}
}

Output:



No comments

2025-26 MCA OBJECT ORIENTED PROGRAMMING WITH JAVA (MCA1105)

OOPS with JAVA (MCA1105) R20 MCA Syllabus – Complete Details & Unit-wise Material Course Objectiv...