Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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

K&B's CD Question...

David Jones

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: illegal start of type
Bing b = new Bing() {"Foo";};
^ <identifier> expected
Bing b = new Bing() {"Foo";};
2 errors
Why such error produced in compiling?
Gian Franco
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
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");
Gian Franco

"Eppur si muove!"
Jarrod Legion

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");
Bing b = new Bing();
You may want to check their Errata page.

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

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
I agree. Here's the link:
subject: K&B's CD Question...
jQuery in Action, 3rd edition