• 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

another confusing question.. get ready

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
given he code

Which of the following options are valid




Select all correct options

a) abstract class Hello implements IHello{ public short hello(short a, short b){ return 0; } }


b) abstract class Hello implements IHello{ public short hello(int a, int b){ return 0; } }


General Comments
The concept here is, the presence of ambiguous methods does not create a problem. A problem occurs when method is calling in an ambiguous way such that the compiler is not able to determine which method to call.


ans given is all are correct valid way.
here is my take on this
-----------------------
i dont see option b) as valid when i put in compiler...
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree to u aruna ......option can't be correct as in that option we're actually trying to overload the method but in a wrong way as we are changing only the return type not the parameter anyway....
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried to compile (b) and I agree with Amit and Aruna. You can't match a method's signature and change its return type.
 
Aruna Agrawal
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all to confirm my belief
[ March 27, 2005: Message edited by: Aruna Agrawal ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic