Author Topic:   Exception and JVM
Divakar
greenhorn
posted March 12, 2000 12:43 AM         
True or false

JVM will not throw any exceptions. Only programs will throw exceptions.


maha anna
bartender
posted March 12, 2000 07:53 AM             
All subclasses of RuntimeException (which is an Exception) and Error are constructed and thrown by JVM at appropriate places, when need comes. All checked exceptions are checked by the compiler whether they are caught properly. Otherwise compile time error occurs. Both Exception and Error can also be thrown by programs through throw new aSubClassOfThrowable(); statement. If the program throws a checked exception(all subclasses of class Exception excluding RuntimeException ) they must be enclosed by try..catch/try..finally/try..catch..finally statements.

So the above statment is not true
regds
maha anna

[This message has been edited by maha anna (edited March 12, 2000).]

Jim Yingst
sheriff
posted March 12, 2000 10:14 AM             
From M.A.'s post:
quote:
If the program throws a checked exception(all subclasses of class Exception excluding RuntimeException ) they must be enclosed by try..catch/try..finally/try..catch..finally statements.

...or they must be declared in the throws clause of the appropriate method(s). As I'm sure you know - just wanted to be complete.

As for Divakar's original question: false, as m.a. said. Exceptions are always thrown by the JVM, usually in response to something in the program. But the program isn't necessarily the cause. Example - if the program is reading data through a connection across the internet, the read() method is declared with a "throws IOException". If I then reach over to the phone line that connects my computer to the internet, and disconnect it, then the JVM will throw an IOException of some sort. Did the program cause this, or did I? I'd say that I did.

maha anna
bartender
posted March 12, 2000 11:05 AM             
Yes Jim , your statement completes the previous post.
regds
maha anna

|