what is difference between throw and throws in exception?
Answer Posted / ajay
Throws keyword suggests that the particular method contains
an Exception and that uncaught Exception is thrown to be
next class where it is supposed to handle(i.e.to be by next
user as he want to handle that exception in his own
way).Simply it throws uncaught exception.But Throws keyword
is used to throw only checked Exceptions and avoids compile
time errors.
And throw keyword,which is used in case of manual
Exception,throw object of corresponding exception from try
to catch just like java implicitely does in cases other than
manual Exception.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a function in programming?
What does function identity () do?
What is a singleton class? Give a practical example of its usage.
If two threads have same priority which thread will be executed first ?
Write an algorithm for quick sort?
which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?
Define inheritance with reference to java.
What is the difference between form & report?
What is unicode in java?
What are keywords in java?
Why declare Main() inside the class in java ?
What is the use of protected in java?
Is ++ operator is thread safe in java?
What is a condition in java?
What is the relationship between class and object?