• 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
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

a simple brainer on inner classes

 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, this is a small piece of code to practice whoever wants it:

[ November 03, 2003: Message edited by: Vad Fogel ]
 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very interesting problem.
Thanks.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Vad,
As the recent recipient of the "Famous Error" award I am now overly sensitive to the issue of compiler errors and questions...
I just wanted to make one point -- on the real exam, we NEVER say "A compiler error on line [whatever]." We always say, "Code will not compile BECAUSE of an error on line [whatever]." Because we cannot guarantee exactly what a particular compiler implementation will actually *report* as the error. For example, if you leave off a curly brace, you know that this produces a compiler error. But WHERE the compiler actually reports the error (and even *what* the compiler reports) might be different from one compiler to another. So, the questions can't ask you exactly what a particular compiler error will be, or even what line the compiler will report (which is why we don't say, "A compiler error on line ..." But instead, the questions ask in which line of code the *actual* error occurred.
So... I just want to make sure that everyone knows how the real exam questions are worded, and why we chose to use that wording. In our "famous error", we didn't specify at which line the compiler errored, we were wrong about the place in the code where the error happened that *caused* the compiler error... it could have been on one of TWO lines, and we were acknowledging only *one* of the two lines of code in which the real error could be.
But after all that, it's quite cool that you're posting questions. There aren't enough of them floating around, and we imagine that everyone is probably getting a little tired of the ones from our book!
Cheers,
Kathy
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathy, I reread your post twice, it's quite a mouthful, but this passage


on the real exam, we NEVER say "A compiler error on line [whatever]." We always say, "Code will not compile BECAUSE of an error on line [whatever]."


must have a kind of mystical power on me, it just keeps on slipping past me. I can't figure out the difference between those two statements on compiler error lines: "before, when everything was wrong...", and "now, as we're smart..."
Could you please, as an example, rephrase the question from page 484 how it'd read now?
[ November 03, 2003: Message edited by: Vad Fogel ]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Asking what line will get a compile error is different than asking which line has a compile error. The compiler may not recognize or it may not report the error on the line that it actually occurred. For example, leave out a semi-colon and the next line is reported as the error line.
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, Thomas, I think I can see your point now
The code

won't compile because of an error on line 1.
Am I correct?
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vad Fogel:
OK, Thomas, I think I can see your point now
The code

won't compile because of an error on line 1.
Am I correct?



The funny thing is that the error could be because of an error on line 2 as well. Add the semi-colon to the beginning of line 2 and it compiles. So where is the real error?
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then, I'm back to the state of confusion out of Kathy's last post.
The compiler gets code statements as tokens delimited by semi-colons. So, it should encounter at least one ending semi-colon after the statement. That semi-colon may appear anywhere after the statement, but before the next statement or the token. If this is correct in general, then how do you think the question on line errors should be worded?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic