• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

q from abhilash's mock exam on try catch

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


I answered the last option, but the correct option is 1st, y.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you think the last option is correct ?
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The rule that the exception named in a catch clause must be throwable by the specific code in the try clause is in the Java Language Specification in Section 14.20, Unreachable Statements, not in Section 14.19, The try statement. I did not find this rule in the K & B or Mughal SJCP books, or even Gosling (The Java Programming Language), so I question whether it will be in the exam.

The Java philosophy is to find every possible error in the compiler, but I think this kind of thing should generate a warning, not an error. There are a lot of other rules like this in JLS Section 14.20. Have a look:
http://java.sun.com/docs/books/jls/second_edition/html/statements.doc.html#79311
[ December 25, 2004: Message edited by: Mike Gershman ]
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic