Program to show - overridden method of subclass can declare/throw any unchecked /RuntimeException

If superclass method throws/declare unchecked/RuntimeException - overridden method of subclass can declare/throw any unchecked /RuntimeException
class SuperClass{
   void method(){
          System.out.println("superClass method");
   }
}

class SubClass extends SuperClass{
   void method() throws NullPointerException{
          System.out.println("SubClass method");
   }
}
/** Copyright (c), AnkitMittal JavaMadeSoEasy.com
* Main class */
public class ExceptionTest {
   public static void main(String[] args) throws Exception {
          SuperClass obj=new SubClass();
          obj.method();
   }
}
/*OUTPUT
SubClass method
*/

eEdit
Must read for you :