Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

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: 41763
885
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.
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic