• 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

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: 41083
848
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.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic