Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

OCA Study Guide Chapter 4 review question 7 option E does not compile

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer on this question on page 343 is I think incorrect. It states that only line 8 will compile (System.out.println(room.floor) but it actually doesn't cos line 6 Classroom room = new Classroom(101, "Mrs. Anderson"); doesn't compile. Hence there is no reference room. Or am I missing something?
 
Bartender
Posts: 3736
39
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Liliane !

I don't have the book, but I can tell you might be right.

When an author writes a question he thinks about the specific line, and Java compiler goes through the whole source code and reports a bunch of related problems as well.

So, here you simply need to understand what is wrong, and wording of the question might be ambigous.

Best regards,
MZ
 
author & internet detective
Posts: 40913
840
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. As we wrote more books, we learned to be more precise with the language of such questions. We'd ask what lines cause compiler errors or the first line to not compile.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic