About Question enthuware.ocajp.i.v7.2.1368 :
Moderator: admin
-
- Posts: 16
- Joined: Wed Feb 25, 2015 8:52 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.1368 :
Can you please give an example of an IllegalStateException?
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Wed Jul 15, 2015 4:05 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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?
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?
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 12
- Joined: Wed Jul 15, 2015 4:05 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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
- 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
-
- Posts: 5
- Joined: Fri Aug 28, 2015 7:24 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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.
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.
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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.
So yes, it is understandably a bit difficult to tell precisely who throws which exception.
If you like our products and services, please help us by posting your review here.
-
- Posts: 26
- Joined: Sun Jul 23, 2017 2:13 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Security exception is thrown by JVM or by Application??
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 26
- Joined: Sun Jul 23, 2017 2:13 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
Ya thanks I have read that but in your enthuware exam it is written that it was thrown by JVM
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1368 :
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.
Also, please make sure you are using the latest version of the question bank.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 50 guests