What is the difference between throw and throws?
Answer Posted / senthil nathan
throws: If a method is not capable of handling the raised
exception and it wants the caller of the method to
handle the exception means then the method uses the
"throws" keyword... The exception raised here is
of System Exception not User Exception...
throw: If the method is capable of handling the exception
by using try&catch block then this method uses the
"throw" keyword.. It is also used to raise our own
exception.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is the final class?
Why is the main method declared static?
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?
Why object class is super class for every class in java?
What is the use of System class?
When the constructor of a class is invoked?
What is equlas() and hashcode() contract in java? Where does it used?
what is a green thread? : Java thread
Why is String immutable?
How to display names of all components in a Container?
Write a program to reverse a number in java?
Can one thread block the other thread?
How will you invoke any external process in java?
How do you clear an arraylist in java?
What does string intern() method do?