If we run it with cmd arguemnt 0 it will print 0. We are sure that in the above code the overridden getInt() method(Subclass version) is calling. Then why we declare main method throws exception,when subclass getInt() method not throwing any exception. Please anyone explain?
Decision about wich overridden method will be called is made at runtime. The compiler doesn't know that the variable of type Utils actually contains a Ping. So we are forced to handle the exception or declare it like done here.