mohitkumar gupta wrote:
if i put the following:
public static void main(String aasd[]) throws Exception
then,only Exception occurs
a.) Why???
If a method declare that it throws a Exception, then the user/caller should take the responsible to handle that exceptions. So, your
foo() method throws exception, so you need to handle it or declare it as re-throwing it in the calling method, in your case, the
main() method
mohitkumar gupta wrote:
b.)If i put RuntimeException instead of Exception in throws clause of foo method then,it not necessay to declare throws RuntimeException in main method throws
clause
WHY???
You don't need to handle the RuntimeExceptions!