which 2 create an anonymous inner class from within class Bang
A. Bang b = new Bing("Foo"){}; b. Bing b = new Bing (343){}; c. Bing b = new Bing(){"Foo";}; d. Bing b = new Bang(){}; e. Bing b = new Bing.Bang("Foo"){};
answer given C & D
I do not understand how C works because when I try to just create a class like this it doesn't work. Can someone please explain.
I saw that too - the { "Foo" }; part does not compile, so it should not have been a correct answer. I believe this is an error in the exam. This probably should go in the Errata forum...
jdmaddison
Steven Bell
Ranch Hand
Joined: Dec 29, 2004
Posts: 1071
posted
0
Are you sure you copied the answers right?
c will create an anonymous class if you remove the String and leave the ; d is fine though.
With the String in place in c you will get a compile error.
Jay Pawar
Ranch Hand
Joined: Aug 27, 2004
Posts: 411
posted
0
Yes that is wrong answer it should be
Bing b = new Bing("Foo"){};
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
If you search this forum for "bing bang" you will see that the general opinion is that it is a typo.