• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Exception questions

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

The following question is from SCExamLab exame Practice 2, question 35.

Look at the following class definitions. Which of the following statement are true? )(Choose four)



[A] Expn1 is a checked exception.
[B] Expn1 is an unchecked exception.
[C] Expn2 is a checked exception
[D] Expn2 is an unchecked exception
[E] Expn3 is a checked exception
[F] Expn3 is an unchecked exception
[G] Expn4 is a checked exception.
[H] Expn4 is an unchecked exception
[I] Expn4 cannot be used as an exception

My answer are B C F I, but the answer from the test are B C E I.

My question is how come Expn3 is a chcked exception here? Can anyone give me an explaination?
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to compile the following program:



You cannot compile this, because java.lang.Throwable is a checked exception. only java.lang.RuntimeException and sub classes are unchecked.
 
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but exceptions are objects, then why I is the correct answer?
 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but you can use instances of classes which are sub-classes of Throwable in the throws and throw clause...
 
Kenneth Lomvey
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Abhi vijay:
but exceptions are objects, then why I is the correct answer?



To use something as an excepion, it MUST be a sub-class of java.lang.Throwable.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic