Page 1 of 1
About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Feb 27, 2015 11:23 am
by dmcinnis1
Can you please give an example of an IllegalStateException?
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Feb 27, 2015 8:39 pm
by admin
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Wed Jul 15, 2015 4:22 pm
by Vermeulen
When I read the question I suspected SecurityException to be thrown by a SecurityManager though I can't remember reading this in the K&B book... Still I selected the answer where it was thrown by the JVM and not the application.
My reasoning was that most applications use the default SecurityManager of the default Java library and do not bother creating their own. So it is not thrown by the application but by the default library...
Should I regard any class, including one in the default Java library, as being part of the application?
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Wed Jul 15, 2015 9:28 pm
by admin
Security manager is not part of the JVM. It is thrown explicitly by regular java code contained in standard Java library just like some other exceptions such as IllegalArgumentException. This code becomes a part of your application. The JVM has no idea about security exception.
HTH,
Paul.
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Thu Jul 16, 2015 2:39 am
by Vermeulen
It certainly does, thank you! Also my compliments for the clear explanation of the answers which helped me understand it. To answer this question with 100% confidence I think the following points really helped.
- "thrown by the application" includes code in Java's standard library
- SecurityException is usually thrown by the SecurityManager in the standard library
and
- you should read "thrown by the JVM" as "thrown implicitly" i.e. without using Java's throw statement in the code
- you should read "thrown by the application" as "thrown explicitly" i.e. by a throw statement in the Java code
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Sep 25, 2015 9:25 am
by danko82
My understanding is:
throws by JVM (unchecked exceptions: implicitly)
throws by Application (eventually some of unchecked exceptions and/or errors, checked exceptions: explicitly)
Generally, RuntimeExceptions are also thrown by the JVM, so it is difficult for me to understand when the RunTime are JVM or can be also by Application.
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Sep 25, 2015 10:09 am
by admin
It is not always black and white. For example, NullPointerException (which is a RTE) is thrown almost always by the JVM but one could throw it explicitly as well from his code. IllegalStateException is commonly thrown by application code.
So yes, it is understandably a bit difficult to tell precisely who throws which exception.
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Thu Aug 17, 2017 3:43 am
by RRRRRR
Security exception is thrown by JVM or by Application??
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Thu Aug 17, 2017 5:13 am
by admin
Did you read the Exception Summary document given with the question bank's study reference section?
4. java.lang.SecurityException extends java.lang.RuntimeException
Thrown if the Security Manager does not permit the operation performed due to restrictions placed by the
JVM. For example, when a java program runs in a sandbox (such as an applet) and it tries to use prohibited
APIs such as File I/O, the security manager throws this exception. Since this exception is explicitly thrown
using the new keyword by a security manager class, it can be considered to be thrown by application
programmer.
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Aug 18, 2017 1:06 am
by RRRRRR
Ya thanks I have read that but in your enthuware exam it is written that it was thrown by JVM
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Posted: Fri Aug 18, 2017 2:45 am
by admin
Where does it say that? Can you please post a screen shot?
Also, please make sure you are using the latest version of the question bank.