int a = 100, b = 0;
int c = a/b;
This is for Tests
class MyException extends Exception
{
public void method() throws XXXX
{
throw new MyException();
}
}
try
{
int arr[]={1,2};
arr[2]=3/0;
System.out.println(a[0]);
}
catch(Exception e)
{
System.out.println("Exception");
}
catch(ArithmeticException e)
{
System.out.println("Divide by Zero");
}
public class test
{
static void method(){}
public static void main(String []args) throws Exception
{
try
{
method();
System.out.println("try");
}
catch(Exception e)
{
System.out.println("catch");
}
finally
{
System.out.println("finally");
}
}
}
This is for Tests
import java.io.*;
class Super
{
void show()
{ System.out.println("parent"); }
}
public class Sub extends Super
{
void show() throws IOException
{ System.out.println("child"); }
public static void main( String[] args )
{
Super s = new Sub();
s.show();
}
}
If Super class method throws an exception, then Subclass overriden method .......
getCause()
method of Throwable is used to ?