About Question enthuware.ocajp.i.v7.2.1368 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
dmcinnis1
Posts: 16
Joined: Wed Feb 25, 2015 8:52 pm
Contact:

About Question enthuware.ocajp.i.v7.2.1368 :

Post by dmcinnis1 »

Can you please give an example of an IllegalStateException?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post by admin »

If you like our products and services, please help us by posting your review here.

Vermeulen
Posts: 12
Joined: Wed Jul 15, 2015 4:05 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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.
If you like our products and services, please help us by posting your review here.

Vermeulen
Posts: 12
Joined: Wed Jul 15, 2015 4:05 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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

danko82
Posts: 5
Joined: Fri Aug 28, 2015 7:24 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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.
If you like our products and services, please help us by posting your review here.

RRRRRR
Posts: 26
Joined: Sun Jul 23, 2017 2:13 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post by RRRRRR »

Security exception is thrown by JVM or by Application??

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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.
If you like our products and services, please help us by posting your review here.

RRRRRR
Posts: 26
Joined: Sun Jul 23, 2017 2:13 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post by RRRRRR »

Ya thanks I have read that but in your enthuware exam it is written that it was thrown by JVM

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1368 :

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests