If you have for instance a method that opens a file and you don't want to handle exceptions inside your method, you need to use the throws keyword to indicate to the compiler that you don't want to handle that here. Otherwise the compiler will cause an error. Also it doesnt just have to be exception in Java, it can be exceptions that you yourself have created.
Ustaad Desraj wrote:...now what if we are not able to see in class
and it have access to BITE too?
than snake will bite?
Any [non-runtime] Exception that can be thrown by a method is part of the method's public programming interface. Those who call a method must know about the exceptions that a method can throw so that they can decide what to do about them. These exceptions are as much a part of that method's programming interface as its parameters and return value.