You need unhandled exceptions or exceptions that extend the RuntimeException class. By default, all unchecked exceptions end up in the default uncaught exception handler , which prints an exception stack trace. If you have not changed the default exception thrower to be different, the behavior you observe when throwing unchecked exceptions will be the same as the one you encounter when a NullPointerException is thrown (another exception thrown).
Note that you will not see the exception stack trace if an unchecked exception hits the caller that acts on it without printing the stack trace. There is no difference in how uncontrolled and checked (those that RuntimeException Exception instead of RuntimeException ) throw exceptions; there is only a difference in which the compiler considers checked and unchecked exceptions.
source share