Bing b= new Bing(){"Foo";}; Bing b=new KAndBExam1();
Those two are given as correct answers. But when I insert option 3 at comment line,it gives �illegal start of type� error.I don�t know how to correct it.Please share your knowledge on this.
You can't just declare a String literal like "Foo" on a line by itself in any type of class (at least none that I'm aware of).
Also no clue what KAndBExam1 is.
You really need to give more of the complete question in order to provide more feedback. (You also mention an 'option 3' which I'm guessing refers to the Bing b = new Bing()... answer?)
Thankyou.I am sorry for lazy to type all options. I got that question from K&B1.4 book Master Exam CD.
Here comes all the options 1) KAndBExam1 b= new Bing("Foo"){}; 2)Bing b=new Bing("343"){}; 3) Bing b= new Bing(){"Foo";}; 4)Bing b=new KAndBExam1(){}; 5)Bing b=new Bing.KAndBExam1("Foo"){};
I am very sure about the given third option is like that.Maybe typo mistake by author.
If I include option 3 at insert code line,How can I access that anonymous class variable(String s=�Foo�);Any comments���