This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
is there any strong demarkation on wht kind of exceptions are thrown by jvm and wht kind of exceptions are thrown by programmer.if we explicitly declare an exception type in our code through throw keyword ,and tht exception type is already known to be thrown typically by jvm,wht will happen? will the jvm take rest ?i mean who will take control of throwing this type of exception? jvm or programmer?
Actually it is said that the responsibility of programmer is upto handling only checked exceptions and jvm will take care about the Runtime exceptions and Errors.
But if these exceptions are thrown explicitly then it becomes mandatory for you to catch these exceptions otherwise the program will stop by not finding the appropriate catch blocks and the control will pass to default handler by jvm.
If you want something you never had, do something you have never done.
is there any strong demarkation on wht kind of exceptions are thrown by jvm and wht kind of exceptions are thrown by programmer
No there is no demarcation of any sort. Though Runtime exceptions can be thrown by the user but shouldn't be and shouldn't actually be handled as well.
Your question sounds a bit ambiguous. The JVM would throw an exception no matter if the user explicitly uses throw or is a result of some code. Consider java exceptions no different from the rest of the exceptions.
i mean who will take control of throwing this type of exception? jvm or programmer?
In case your code resulted in an exception the JVM would throw it for you or if you want you can explcitly ask the JVM to throw an exception for you.