What is the difference between throw and throws?

Showing Answers 1 - 6 of 6 Answers

kiran

  • Nov 27th, 2006
 

throw - It is used to throw an Exception.The throw statement requires a single argument : a throwable class object throws - This is used to specifies that the method can throw exception

  Was this answer useful?  Yes

throw enables ur program  to throw an exception explicitily.
general form is     throw  abc

abc is an object of type Throwable or subclass of Throwable.


throws : if a method is capable of causing an exception that it doesnot handle ,it must specify this behaviour so that callers of the method can  guard themselves against the exception.
throws clause lists the types of exception that a method might throw.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions