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
This abstract class is correct ? abstract class A { public abstract void Disp(); public abstract void B() { } public absract virtual C() { } }
What is the default value of float and double datatype in java?
Why method overriding is used?
What is a parameter in java?
Where are register variables stored?
What are peerless components?
What is the purpose of file class?
Can we use static class instead of singleton?
What is hashing principle in java?
Is Constructor possible in abstract class in java ?
Are primitives objects?
What is return used for in java?
What is a map? What are the implementations of map?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread
Is java good for beginners?