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
What is the difference between char and char *?
What is difference between identifier and variable?
What is the difference between reader/writer and inputstream/output stream?
How will you communicate between two applets?
How to make a write-only class in java?
What are 5 boolean operators?
What is ++ a in java?
What is the use of optional ?
How do you access command-line arguments within the code?
How do you write a scanner class in java?
Are arrays primitive data types?
What are implicit objects in java?
How to Sort Strings which are given in List and display in ascending order without using java api.
What is ternary operator in java?
What do you understand by synchronization?