• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Helllp..... Anon Class - Kathy & Bert's CD

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I ahve come across this problem in Kathy & Bert's CD. I could not understand a bit and I am getting error when i try to compile the program also. Can anyone explain?
Question: Given the following:

Which two would create and anonymous inner class from within the class Bang?
Choices:
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 : C & D.
I feel answer A and D are correct; C is not even working for me!!!
Please explain. Moreover thsi software is not good at all. It doesn't let me do even copy and paste at all. It even declares that i failed when scored 77%.

Regards,
Raman
Edited by Corey McGlone: Added CODE Tags
[ March 11, 2004: Message edited by: Corey McGlone ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer C is indeed incorrect. It has a typo. For the discussion see here:
https://coderanch.com/t/241104/java-programmer-SCJP/certification/comprehensive-exam-kathy-Bert-book
Answer A is wrong because it is trying to refer to a superclass using a variable declared as a subclass. It would work fine the other way around, (like answer D in fact) but not this way.
Finally you've got a small transcription error in your code. It should be:
Bang(String bangS) {super(bangS);}
(note the punctuation)
 
Padma Raman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks a lot.
Regards,
Raman
 
reply
    Bookmark Topic Watch Topic
  • New Topic