• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Sybex 816 Custom Assessment question 10 with code [tb617624.JaSE11PrgIISG.at.13] possible error

 
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The explanation says

Line 10 includes an unhandled checked IOException, while line 11 includes an unhandled checked FileNotFoundException

but none of BufferedInputStream's constructors declare a checked Exception. I think the author meant to say ?

Line 9 includes an unhandled checked IOException

 
author & internet detective
Posts: 40487
823
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Confirmed and added to the errata crediting you. Thanks!

Note: This is actually question 13. You were probably using the randomizer online for question order. (Which is the default online)
 
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Olivia Johnson wrote:
The explanation says

Line 10 includes an unhandled checked IOException, while line 11 includes an unhandled checked FileNotFoundException

but none of BufferedInputStream's constructors declare a checked Exception.



If you compile code as it is, compiler will complain only about incompatible casting from Object to Bird.

If you fix it adding appropriate cast, compiler will show compile errors on other lines, including line 9 - "exception thrown from implicit call to close() on resource variable 'is'".

Compiler flags unhandled exceptions, thrown by close() method of the variable in try-with-resourses statement, at the point of declaration of such variable.
 
reply
    Bookmark Topic Watch Topic
  • New Topic