• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Reg. Overriding : Valiveru's exam

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


Which of the following are true about overloading & overridding.
A.Overrided methods return different return types and
will be in different classes.
B.Overloaded methods supplement where as overridden
method replace the method it overrides.
C.Return type of overriden method must be identical to
return type of method it overrides.
D.Given a method
public void aMethod(int i,float f);
the method
public void aMethod(float f,int i);
is a possible overridden method.


I assume the correct answers are B, C
What is the exact meaning of supplement in answer B.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angela!
The overloaded methods suplement because they have difernts parameters whereas overriden methos have the same parameters.
Hope thats help.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i agree , only B & C are correct
A) Overrriden methods return same return-type
D) Given methods are ex of overloading , not overriding

Meaning of supplement in B is , tht most of the times overloaded methods Supplements/ADDS to the functionality of original methods , providing functionality based on da types of arguments
like we hav float amethod( int , float )
then two overloaded methods ;
float amethod( int i ) { amethod(i, 0.0f) ; }
float amethod( float f ) { amethod(0 , f ) ; }
are supplementing the original method
where as overriden methods mostly replaces the original declaration ( tho they can call original method wid super.method() )
I knw dat isnt very gud xplanation , but somehow i ran outta words on dis
anybdy else , ur opinions plzz

------------------
Gagan (/^_^\)
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
supplement means enhance the functionality.
e.g. you have the following methods:

public void print(String s){
System.out.prinln(s);
}
public void print(int i){
System.out.prinln(i);
}
public void print(float f){
System.out.prinln(f);
}
These 3 methods are all printing, but in each method they are printing a different thing. Basically in overlaoding the method name is the same, but parameter list is different.
Hope this helps,

------------------
Asma Zafar,
Sun Certified Programmer for Java2 Platform
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic