answersLogoWhite

0

throws exception is a common signature pattern for methods. It is used to signify the fact that the code inside the method may throw exceptions of the types mentioned in the method signature. The calling method must have code to handle the exception effectively.

Ex:

public String getName() throws SQLException {

.....

}

This method's code can throw an SQLEXception and the calling method must have the code to handle this exception

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What keyword are used in java for exception handling?

The important keywords used in Java with respect to Exception Handling are: a. Throw - The "throw" keyword is used to throw exceptions from inside a method b. Throws - The "throws" keyword is used to signify the fact that the code contents within the current method may be throwing an exception and the calling method must handle them appropriately


What is the difference between throw and throws in net?

"throw" is the keyword to raise an exception. "throws" is a Java keyword that indicates a specific method can potentially raise a named exception. There is no analog in VB.Net or C#. Perhaps there is a "throws" keyword in J#?


What does the warning Illegal Argument Exception mean in Java language?

The warning Illegal Argument Exception in Java means that one has attempted to pass a wrong type of argument for a function. For example, we have a function that calculates a sum of two numbers and feed it a text string, which results in Illegal Argument Exception.


What is throw exception in java?

The presence of the keywords "throws exception" on a method signature means that, the method may throw an exception whhich it does not handle. It also means that the method that is calling or invoking it has to handle such exceptions. If the calling method does not handle that exception it would have to in turn use the same "throws exception" clause and throw it to its parent method.


Why should throw keyword is used in java?

Use it when you are implementing something that says it throws a certain exception when a certain condition is met.


What is the use of throw statement?

throws keyword/statement is basically used to handle exception in java. throws keyword is used to handle "unchecked exceptions". Example: public void enterdata()throws IOException { BufferedReader inp=new BufferedReader(new InputStreamReader(System.in)); int i=Integer.parseInt(inp.readLine()); } Now after the enterdata function we have used throws keyword because the"readLine" method throws an unchecked exception ie., IOException during user input which cannot be handled by try catch block.


How an exception subclass is created in java explain?

We can create a exception sub class by extending Exception class available in java


Does throws throws only unchecked exception?

You can throw any type of exception you want, including an unchecked exception.


Why use throw in java in compare try-catch?

we use throws in our program so that we dont need to write try & catch block & to avoid the exception


What is the purpose of NoMatchException handling method in java?

java exception


How exception handling differs in C plus plus and Java?

Exception handling is largely the same for both. The only real difference is that C++ has no 'finally' clause which always executes whether an exception occurs or not. Another difference is that Java throws exceptions and errors, but errors cannot be handled since programs cannot handle errors -- such as the JVM out of memory error.


Which exception is thrown by the add method of Collection interface in java?

exception