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
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
Do I need java on my pc?
what is inner class in java?
What is string :: npos?
How do you clear a list in java?
What are facelets templates?
Give reasons supporting that string is immutable.
What is the difference between method overriding and overloading?
What is polymorphism java example?
Do you know how to reverse string in java?
What is the difference between error and an exception?
What is the difference between the boolean & operator and the && operator in java programming?
Why we go for collections in java?
How the metacharacters are different from the ordinary characters?
What are exceptions