Skip to main content

Posts

Showing posts with the label throws keyword

Exception Propagation and throw-throws keyword

Exception Propagation: Sending exception from one method to another method is called exception propagation Here propagation is nothing but sending. So guys what is the situation when we are going to implement this propagation concept? Answer to this question is when we throw an exception, if it is not caught in that method it is propagated to another method and interesting thing is that we don’t need to do anything in this process we just need to throw an exception that’s it. Rule: If the propagated exception is checked exception then not only current method developer but also method’s caller method developer should caught or report that checked exception else it leads to same compiler exception….CE: Unreported Exception So according to that basic rule is “If checked exception is raised the method either directly by using throw keyword or indirectly by a method call it must be caught or reported. void m1() throws ClassNotFoundException{ ...