what difference between throw and throws in exception
handling.

Answers were Sorted based on User's Feedback



what difference between throw and throws in exception handling...

Answer / narayana reddy

throws indicates what type of exception is thrown by
a particular function, where as throw is used to through
user defined exceptions

Is This Answer Correct ?    14 Yes 0 No

what difference between throw and throws in exception handling...

Answer / archana

throws is to handle exception by the system itself
whereas throw used by the user to handled the exception

Is This Answer Correct ?    5 Yes 0 No

what difference between throw and throws in exception handling...

Answer / sidd

In case of java if any error occur deuring the exicution
time throw is use to throwing that that into our catch block
for handling and in case of throws if any error
will occur throws can handle that error.

Is This Answer Correct ?    1 Yes 0 No

what difference between throw and throws in exception handling...

Answer / dani

You can declare multiple exception thrown by method in
throws keyword by separating them in common
e.g. throws IOException, ArrayIndexBoundException etc,

while you can only throw one instance of exception using
throw keyword e.g. throw new IOException("not able to open
connection").

Is This Answer Correct ?    1 Yes 0 No

what difference between throw and throws in exception handling...

Answer / aravinda reddy

Whenever we want to force an exception then we use throw
keyword,throw keyword can also be used to pass a custom
message to the exception handling module i.e. the message
which we want to be printed. throw we will use at statement
level.

Whereas when we know that a particular exception may be
thrown or to pass a possible exception then we use throws
keyword. Point to note here is that the Java compiler very
well knows about the exceptions thrown by some methods so
it insists us to handle them. Method Level

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Core Java Interview Questions

if num=687; U have to get num=6+8+7;

4 Answers   CMC,


Nullpointer exception is a very common exception. Why is it not made as a checked exception?

2 Answers   Ness Technologies,


Is intellij better than eclipse?

0 Answers  


Which graphs are functions?

0 Answers  


how to call one program .class file in another program

7 Answers   TCS,


What is return code?

0 Answers  


Write a code to show a static variable?

0 Answers  


what are the differences between java and .net?..why u choose java?

1 Answers  


Why Do I Get A "permission Denied" Error After Downloading The .jnlp Java Launcher For The Vkvm?

0 Answers   Cisco,


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

0 Answers  


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

0 Answers  


Write a java program to check if a number is prime or not?

0 Answers  


Categories