• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

HELP ME IN THIS REGARD

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following most closely describes the process of overriding?
1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy
2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy
3) A method with the same name but different parameters gives multiple uses for the same method name
4) A class is prevented from accessing methods in its immediate ancestor
ANSWER:
2) A method with the same name completly replaces the functionality of a method earlier in the hierarchy
Option 3 is more like a description of overloading. I like to remind myself of the difference between overloading and overriding in that an overriden method is like something overriden in the road, it is squashed, flat no longer used and replaced by something else. An overloaded method has been given extra work to do (it is loaded up with work), but it is still being used in its original format. This is just my little mind trick and doesn't match to anything that Java is doing.
I CANNOT UNDERSTAND Y OPTION 3 IS NOT CORRECT.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajani,
For overriding, the number of parameters, method name and return type in the overriding and the overridden methods should be the same. Option 3 does not fit into the above condition.
Hope this helps.
bye,
Natarajan
 
rajani adapa
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THANKS NATCHIT,
but my question is :
why option 3 is not correct?
i think overloading means the same method with different parameters to obtain multiple uses.
please explain me breifly.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rajani adapa:
Which of the following most closely describes the process of overriding?
1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy
2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy
3) A method with the same name but different parameters gives multiple uses for the same method name
4) A class is prevented from accessing methods in its immediate ancestor
ANSWER:
2) A method with the same name completly replaces the functionality of a method earlier in the hierarchy
Option 3 is more like a description of overloading. I like to remind myself of the difference between overloading and overriding in that an overriden method is like something overriden in the road, it is squashed, flat no longer used and replaced by something else. An overloaded method has been given extra work to do (it is loaded up with work), but it is still being used in its original format. This is just my little mind trick and doesn't match to anything that Java is doing.
I CANNOT UNDERSTAND Y OPTION 3 IS NOT CORRECT.


Rajani your question is about overriding hance option 3 is not correct. It will be correct for overloading.
Hope this help
Amit

[This message has been edited by Amit, Jhalani (edited February 01, 2001).]
 
rajani adapa
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops.
i got it.
i didn't even studied the question properly
thanks amit
 
reply
    Bookmark Topic Watch Topic
  • New Topic