Professional Documents
Culture Documents
ABHISHEK CHOUDHARY
07311503113
AIM
Exception Handling
(A) Write an program using try , catch and throw.
(B) Create your own exception class
(A) SOURCE CODE
class Exc
{
public static void main(String args[])
{
try
{
if(Integer.parseInt(args[0])<18)
{
throw new ArithmeticException("Not Valid");
}
else
{
System.out.println("Welcome");
}
}
catch(ArithmeticException e)
{
System.out.println(e);
}
}
}
OUTPUT