answersLogoWhite

0

What is the use of throw statement?

User Avatar

Anonymous

13y ago
Updated: 8/20/2019

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.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Throws statement in java?

throw new Throwable(); or throw new Error("Danger will Robinson!"); or throw new NullPointerException(); etc.


What is the difference between a declarative statement and an imperative statement?

In a declarative statement, you initialize the object. But in an imperative statement, you use a preexisting statement and use it.


What is the difference between 'switch' statement and 'if' statement?

we can use switch statement in multiple time but in if statement we can not use multiple time


Can a continue statement be used in a switch statement?

If you have a loop in your switch statement or around your switch statement, you can use the continue statement in that. You cannot use a continue statement outside of a loop (do, for, or while).


How can you access the value throw an array?

You cannot throw an array, only exceptions can be thrown. You access the thrown exception by catching it in a catch clause of a try...catch statement.


Does a guy like you if he told you that he thought girls just use him and throw him to the curb?

This statement alone is not an indication one way or another that the boy likes you, at least not for anything more than a friend.


What argumentative statement is a claim of value?

its is irresponsible to throw away uneaten food.-Apex


What is the origin of the idiom what can sorry do?

Sorry is a passive statement and refers to events that have past and so can not really do anything. It is a retort by someone who is upset to throw the statement back in the face of the apologiser.


Can you use the pronoun "I" in a thesis statement?

Yes, it is generally not recommended to use the pronoun "I" in a thesis statement as it can make the statement less objective and formal.


How do you use statement in a sentence?

A statement is a sentence that conveys information or opinion. In writing, you can use a statement to make a point or provide a fact. For example, "Her statement about the company's financial situation was concerning."


Where can you use a personal mission statement?

you can use a personal mission statement in your work or in daily life!


What is aclrsi on credit card statement?

statement which is properly use in.