What is the difference between throw and throws?
Answer Posted / manish kushwaha
First of all i would say both are reserved keyword in java
In Java Exception handling we are using above keyword throw
and throws.
Difference:
throws: throws clause is always use to propagate method
level exception, when ever you will use this clause, caller
method responsibility is to handle exception trowed by the
same method.
throw: this is the clause use to throw the instance of that
exception, main use of this throw clause is in user define
exception use you have written your own exception when ever
this exception will come you will throw this exception object.
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
how its run?
How do you declare a variable?
What is java argument list?
Explain notify() method of object class ?
What is the primitive type byte?
What is downcasting?
Why do we need strings in java?
What is a "pure virtual" member function?
What is number data type in java?
What is a double vs float?
Does java support function overloading, pointers, structures, unions or linked lists?
Explain the importance of join() method in thread class?
How do you add an element to a hashset in java?
What is the use of keywords in java?
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?