In C++ what is the use of 'try' block? (when we are clearly 'throw'ing the issue) I think in Java, exception can be find at any place in the 'try' block.
otherwise 'try' is syntactical requirement to make 'throw' works?
In C++ you don't need to mark that a function can throw exceptions. I guess you can think of them as unchecked exception in Java, like ArrayIndexOutOfBoundsException and NullPointerException, that does not require you to catch or mark the method as throwing.
On the contrary, in C++, if you know that a function can't throw exceptions you can mark it with noexcept if you want.
I don't know Java. Less is more seems to be the guideline for exceptions.
The focus should be on catch, like coder777 says. Catch what? From where? If this block X of code throws any of these exceptions Y, then I want to intercept and do Z.
By default we probably don't catch and handle anything from anywhere (at least on homework trivia). Therefore, the uncaught exceptions unwind the call stack all the way to main() and beyond. Looks like a crash of some sort.
What we might prefer is to choose operations that never throw. We then handle the error situations by other means than exceptions.