• 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

anonymous inner class

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,everybody

Given the following,



Which two create an anonymous inner class from within the class Bang ?

  • Bang b = new Bing("Foo"){};
  • Bing b = new Bing(343){};
  • Bing b = new Bing(){"Foo";};
  • Bing b = new Bang(){};
  • Bing b = new Bing.Bang("Foo"){};



  • The reference answer is C & D.Why the answer C is correct answer? Could anybody give me a explanation.
     
    Ranch Hand
    Posts: 225
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Imagine that the statement Super(bangs); is replaced with super(bangs) (code won't compile otherwise), C is incorrect because the statement "Foo"; is invalid.
     
    gangqiang zhang
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks, seb

    The question is on the CD of K&B's book.
     
    Ranch Hand
    Posts: 68
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    what makes the answer>annonymous class ? I thought to make it annonymous you haveto extends or implements there and then the answer looks like a normal innerdass only
     
    gangqiang zhang
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thx,
     
    gangqiang zhang
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    Hence,I can get another anonymouse inner class like the preceding code.It is a subclass of Bing class.

    Regards

    zhang
     
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    That's lapsus calami .
     
    There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic