This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B's CD Question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B Watch "K&B New topic
Author

K&B's CD Question...

David Jones
Greenhorn

Joined: Dec 26, 2003
Posts: 27
Hi all,
Here is the question from K&B's CD:
class Bing {
Bing(String s) {};
Bing() {};
}
class Bang extends Bing {
Bang() {};
Bang(String bangS) {super(bangS);};
// inserted here
}
The question is which line can be inserted at // without produces error. One answer is
Bing b = new Bing() {"Foo";};
However, I am not understand why the above statement is OK. So I inserted this line and compile, following error is raised:
Bang.java:9: illegal start of type
Bing b = new Bing() {"Foo";};
^
Bang.java:9: <identifier> expected
Bing b = new Bing() {"Foo";};
^
2 errors
Why such error produced in compiling?
Thanks,
David
Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
Hi,
I wouldn't like to contradict Kathy or Bert ,
and see a spell cast on me now that I'm preparing
for the SCJP...
...but the answer doesn't look correct,
I can't compile it either, maybe it should have
been: Bing b = new Bing("Foo");
greetings,
Gian Franco


"Eppur si muove!"
Jarrod Legion
Greenhorn

Joined: Dec 24, 2002
Posts: 18
Hi David,
From what you've posted it looks like a syntax error
As Gian has pointed out, it should either be
Bing b = new Bing("Foo");
or
Bing b = new Bing();
You may want to check their Errata page.

Cheers,
-Jarrod
Raja Sagar Panamgipalli
Ranch Hand

Joined: Aug 13, 2003
Posts: 109
True Jarrod ,
there seems to be syntax error...or mistype...


SCJP 1.4<br />SCBCD 1.3
David Jones
Greenhorn

Joined: Dec 26, 2003
Posts: 27
Hi Jarrod,
I did not find errata page related to this question. It seems that it is a typo now
David
 
GeeCON Prague 2014
 
subject: K&B's CD Question...