Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chapter 6 Exceptions, Question 5 (Java OCA 8 Programmer I Study Guide, Sybex)

 
Jakub Turoboś
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 6 Exceptions, Question 18 from Java OCA 8 Programmer I Study Guide by Jeanne Boyarsky and Scott Selikoff

5. Which of the following exceptions are thrown by the JVM? (Choose all that apply)
A. ArrayIndexOutOfBoundsException
B. ExceptionInInitializerError
C. java.io.IOException
D. NullPointerException
E. NumberFormatException

Answer at the end is A,B,D, but ExceptionInInitializerError is an Error not an Exception, so shouldn't it just be A,D?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jakub,
Welcome to CodeRanch!

The book is correct. An "exception" is a concept that means something exceptional happened. It includes the any Throwable type. An Exception is a class in Java of which errors are not a subclass.
 
Jakub Turoboś
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Jakub,
Welcome to CodeRanch!

The book is correct. An "exception" is a concept that means something exceptional happened. It includes the any Throwable type. An Exception is a class in Java of which errors are not a subclass.


Yes, it makes sense. I interpreted "exceptions" as java.lang.Exception and all subclasses.
Thank you for the explanation.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jakub Turoboś,

First of all, a warm welcome to CodeRanch!

Jakub Turoboś wrote:I interpreted "exceptions" as java.lang.Exception and all subclasses.

If the question would have been "Which of the following Exception classes are thrown by the JVM?", then your interpretation would have been correct

On the exam it's really important to carefully read the questions. Because one word or even one letter can make a difference between a correct and an incorrect answer. But on the actual exam, each question always mentions how many correct answers you have to select, so that's sometimes very, very helpful (e.g. a questions could ask you to select which answers are "not true"; if you didn't spot "not", you'll select all true statements and you'll end up with 4 "correct" statements whereas you only had to select two).

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic