File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes AssertionError - JVM or Programmer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "AssertionError - JVM or Programmer" Watch "AssertionError - JVM or Programmer" New topic

AssertionError - JVM or Programmer

Jared Cope
Ranch Hand

Joined: Aug 18, 2004
Posts: 243

I am doing a mock exam from Java Inquisition and was surprised to see that in a question regarding whether the JVM or a programmer typically throws an AssertionError, the answer was the programmer.

I thought it would have been the JVM as I've never seen code explicitly doing:

Isn't it always thrown as part of the assert mechanism run by the JVM? Backed up in another argument that assertions are disabled or enabled by the JVM at runtime?

Cheers, Jared.

SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
Jitendra Jha
Ranch Hand

Joined: Jan 28, 2007
Posts: 91
Programmetic or Jvm error/exception does not mean that,you through it explicitly or not.It means that,the cause of the error is something from code(maybe some unexpected solution in case of programetic) or the problem is with an error which might disturb the JVM in some unexpected way.

Hope i am right

maredu ramesh

Joined: Sep 14, 2007
Posts: 4
It means that,the cause of the error is something from code(maybe some unexpected solution in case of programetic)

Can you please explain this.
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Basically, the idea behind the concept of "programmatically thrown exceptions" is that these are exceptions where the programmer deliberately and explicitly indicates an intention to possibly throw an exception. When you write an assert statement, you are explicitly creating the possibility of an AssertionError being thrown there.

In contrast, a "JVM thrown exception" occurs implicitly, i.e. without the Java programmer's deliberately declared intent. These happen most often when an expression evaluation stops prematurely (e.g. ArrayIndexOutOfBoundsException) or when the JVM itself encounters a problem (e.g. OutOfMemoryError).

SCJP 5.0
I agree. Here's the link:
subject: AssertionError - JVM or Programmer
It's not a secret anymore!