what is difference between throw and throws in exception?
Answer Posted / raju
throw : throw is used to throw user defined exceptions.
For ex: MyException written by user.it may be either
checked or unchecked exception.
throws: throws is used to throw exception those are handled by
JVM directly.
throws is used in method declaration to
intimate user that, it throw the exception that must
be handled by calling method.
Note :use throws when your method does not handle exception.
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Can constructor be inherited?
What is the arraylist in java?
Why main method is called first in java?
How is treeset implemented in java?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
What does isempty () do in java?
Where can i get Latest SUN Certification Dumps and what are the Sun Certification Codes that are available, Im new to JAVA, so please gimme info as i need to write J2EE - Core Java Certification
why using interface interface ?
Is array size fixed in java?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
What is difference between ++ I and I ++ in java?
What are advantages of using Java?s layout managers than windowing systems?
What are the types of exceptions?
how to prepare for IT Officers Interview in Banks
What is an empty class? What functionality does it offer in Java?