0% found this document useful (0 votes)
26 views

Java Programming: Program 5: Write A Program in Java For Exception Handling

The document is a program submission for a Java programming course. It includes source code that demonstrates exception handling in Java. The code defines a Test class with doStuff() and doMoreStuff() methods. doMoreStuff() contains a divide by zero operation that throws an ArithmeticException. This exception is caught in the try-catch block within the main method, where it prints "Exception handled in main method".

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Java Programming: Program 5: Write A Program in Java For Exception Handling

The document is a program submission for a Java programming course. It includes source code that demonstrates exception handling in Java. The code defines a Test class with doStuff() and doMoreStuff() methods. doMoreStuff() contains a divide by zero operation that throws an ArithmeticException. This exception is caught in the try-catch block within the main method, where it prints "Exception handled in main method".

Uploaded by

umair riaz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

JAVA PROGRAMMING

(DCO-515)

Program 5: Write a program in java for Exception Handling.

Submitted by:
UMAIR RIAZ
Roll. No. 16-DCS-067
Diploma in Computer Engineering- V Semester

Computer Engineering Section


University Polytechnic, Faculty of Engineering and Technology
Jamia Millia Islamia (A Central University)
New Delhi-110025
Session 2018-2019
Exception Handling
#Source Code
class Test
{
void doMoreStuff()
{
System.out.println("Do more Stuff-1");
System.out.println(10%0);
System.out.println("Do more Stuff-2");
}
void doStuff()
{
System.out.println("Do more-1");
doMoreStuff();
System.out.println("Do more -2");
}
public static void main(String [] args)
{
Test t=new Test();
try
{
t.doStuff();
}
catch (Exception e)
{
System.out.println("Exception handled in main method");
}
}
}
//Output

You might also like