File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a simple brainer on inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a simple brainer on inner classes" Watch "a simple brainer on inner classes" New topic
Author

a simple brainer on inner classes

Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Hi, this is a small piece of code to practice whoever wants it:

[ November 03, 2003: Message edited by: Vad Fogel ]
Cathy Song
Ranch Hand

Joined: Aug 24, 2003
Posts: 270
Very interesting problem.
Thanks.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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

Joined: Aug 25, 2003
Posts: 504
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 ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
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
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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

Joined: Aug 25, 2003
Posts: 504
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a simple brainer on inner classes