java the throw 2fthrows keyword

Solutions on MaxInterview for java the throw 2fthrows keyword by the best coders in the world

showing results for - "java the throw 2fthrows keyword"
Dianna
20 Jul 2016
1//f a method does not handle a checked exception, the method must declare it using the throws keyword. The throws keyword appears at the end of a method's signature. 
2One can throw an exception, either a newly instantiated one or an exception that you just caught, by using the throw keyword. 
3Understand the difference between throws and throw keywords, throws is used to postpone the handling of a checked exception and throw is used to invoke an exception explicitly. 
4Example
5import java.io.*;
6public class className {
7
8   public void deposit(double amount) throws RemoteException {
9      // Method implementation
10      throw new RemoteException();
11   }
12   // Remainder of class definition
13}