Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg. Overriding : Valiveru's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg. Overriding : Valiveru Watch "Reg. Overriding : Valiveru New topic
Author

Reg. Overriding : Valiveru's exam

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327

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.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Angela!
The overloaded methods suplement because they have difernts parameters whereas overriden methos have the same parameters.
Hope thats help.
Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
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 (/^_^\)


Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
Asma Zafar
Ranch Hand

Joined: May 11, 2001
Posts: 49
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


Asma Zafar,<BR>Sun Certified Programmer for Java2 Platform
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reg. Overriding : Valiveru's exam
 
Similar Threads
overriding
Q from javacross simulation
overloaded methods
Overidding Methods
Overload methods in subclass?