I am trying to understand throws clause in JAVA , I wrote the following
piece of code:
class check
{
    static void demo()
    {
        System.out.println("Hello\n");
        throw new IllegalAccessException("demo");
    }
    public static void main(String args[])
    {
        demo();
    }
}
I understand that it won't compile as the exception has to be handled
in the main method and demo() should be defined with specifying a throws
clause for IllegalAccessException.
But when I change the exception to NullPointerException, the same
program compiles and executes:
class check
{
    static void demo()
    {
    System.out.println("Hello\n");
    throw new NullPointerException("Demo");
    }
    public static void main(String args[])
    {
    demo();
    }
}
