What is the difference between throw and throws?

Answer Posted / kanhaiya sharma

throws :- throws clause is used when programmer does
not want to handle to the exception and throw it out of a
method.

throw :- throw clause is used when programmer wants to
throw an exception explicitely and wants to handle it using
catch block. hence throws and throw is contradictory.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bytecode in java ?

830


If two threads have same priority which thread will be executed first ?

1123


do I need to use synchronized on setvalue(int)? : Java thread

744


How to Sort Strings which are given in List and display in ascending order without using java api.

4070


What are the five major types of reference sources?

726


Is ++ operator is thread safe in java?

689


What is n in java?

718


What is string manipulation?

705


Tell me about your ability to work under pressure

1944


What is the purpose of methodology?

833


What is the original name of java?

767


Why is singleton class used?

761


What is method overloading and method overriding?

746


Define an enumeration?

793


How do you write a conditional statement?

698