// Overriding when superclass method does not declare an exception 
// Driver class
class ExceptionDemo1 {
  public static void main( String[ ] args ) {
    Parent obj = new Child( );
    obj.m1( );
  }
}
class Parent { 
  void m1( ) { System.out.println( "From parent m1( )" ); } 
  void m2( ) { System.out.println( "From parent m2( )" ); } 
} 
class Child extends Parent { 
  @Override
  // Not issuing while throwing unchecked exception. 
  void m1( ) throws ArithmeticException {
    System.out.println( "From child m1( )" );
  } 
  @Override
  // Compilation error 
  // Issuing while throwing checked exception.
  void m2( ) throws Exception{
    System.out.println( "From child m2" ); 
  } 
}
    
    |