• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AssertionError - JVM or Programmer

 
Jared Cope
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
 
Jitendra Jha
Ranch Hand
Posts: 92
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 513
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic