title: Java: IllegalAccessException
body: <p>There is an error while compiling this. Whereas there is no error when I try to throw a NullPointerException.
  Could anyone please help me on this one?
  Thanks.</p>
  
  <pre><code>class ThrowsDemo {
      static void throwOne(){
          System.out.println("Inside throwOne.");
          throw new IllegalAccessException("demo");
      }
  
  
      public static void main(String args[]){
          try{
              throwOne();
          } catch (IllegalAccessException e) {
              System.out.println("Caught " + e);
          }
      }
  }
  </code></pre>