answersLogoWhite

0

Throws statement in java

Updated: 8/19/2019
User Avatar

Wiki User

13y ago

Best Answer

throw new Throwable();

or

throw new Error("Danger will Robinson!");

or

throw new NullPointerException();

etc.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Throws statement in java
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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.


What advantage does Java's break statement have over C's break statement?

They do the same thing, but only the former can be used in a Java program.


What does do in java?

You never write "do" seperately in Java. The only situation I can think of when you have to write "do" is in the "do while" statement. This is the syntax: do { statement(s) } while (expression);


What are semicolons used in java?

to end a statement


What is case in java?

Case is used to label each branch in the switch statement in Java Program


What is a simple java code and explain what the code does?

int a;This simple Java statement declares an integer.


What is the use of switch statement in java?

In java, a switch statement is used to simplify a long list of 'if' statements. A switch statement takes the form of:switch (variableName){case condition1; command1;case condition2; command2;...}


What is the statement that every Java application must contain?

free download


How are java program statements terminated?

Each statement in Java ends with a semicolon, for example: int a; a = 5; int b = 10;


What is called OR in Java programming?

If you are going to make an if statement with or, use: Isn't that easy!


In a java statement Math.sqrt what is Math and what is sqrt?

Math is the class, and sqrt() is the method.


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