-3

THROW:-We have to handle the exception(we in the sense user here).

Throws:We are asking the compiler to handle the exception raised.

Please correct if what I stated above is wrong . If wrong please tell me the correct statement.

Thanks in Adv!

user3300851
  • 87
  • 1
  • 3
  • 12
  • 1
    Are these quiz questions? Anyways, both are easily searchable. [`throw`](http://docs.oracle.com/javase/tutorial/essential/exceptions/throwing.html). [`throws`](http://docs.oracle.com/javase/tutorial/essential/exceptions/declaring.html). – Jason C Mar 24 '14 at 07:23
  • @JasonC no they are not.i just wanted to know what I have understood is correct or wrong.so if u can please help! – user3300851 Mar 24 '14 at 07:24

1 Answers1

1

I'd say that both are not exact.

throw statement causes throwing of exception. No-one has to catch it however. For example runtime exception can be thrown without any requirement to catch them in application code.

throws is a keyword that allows to declare that method may throw exception of specific type.

Not a bug
  • 4,286
  • 2
  • 40
  • 80
AlexR
  • 114,158
  • 16
  • 130
  • 208
  • 2
    Adding to this, their usage is similar to their usage in English. If I say `throw the ball`, I am giving a command to do something (throw the ball). If I say that something `throws the ball`, I am declaring the action that something may take. – Jason C Mar 24 '14 at 07:28
  • @Jason C, +1 for English meaning. I am afraid however that linguistics does not help to OP too much. – AlexR Mar 24 '14 at 07:48