aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is Return Type Included in Method Signature ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is Return Type Included in Method Signature ?" Watch "Is Return Type Included in Method Signature ?" New topic
Author

Is Return Type Included in Method Signature ?

vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
Hello All,

Can any one tell me return type included in method signature or not.
if yes then
Suppose a case when
Two Classes are there A & B.
B extends A.
Now

class classBase{
public A method (){
.........
...........
return new A();
}
}
class classChild extends classBase{
public B method(){
.........
...........
return new B();

}
}
The Question is
In this case Overriding is happening or not.
[ June 30, 2006: Message edited by: vijay saraf ]

Thanks
Vijay Saraf.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

No, this is not valid. Return type has to be the same.


[My Blog]
All roads lead to JavaRanch
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
it means return type should exactly be the same as in base class's method.
but i have read somewhere that signature means
method name and parameter list.....excluding return type.is it ok??
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
A method's signature is its name and the number and the type of its arguments. The method return type, method modifiers, and declared thrown exceptions have no effect on the method signature.
S Thiyanesh
Ranch Hand

Joined: Mar 19, 2006
Posts: 142
but i have read somewhere that signature means
method name and parameter list.....excluding return type.is it ok??

This is called as Covariant return types included from Java 5.


This is a perfect override for SCJP 1.5 but a compiler error for SCJP 1.4.
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
thanks all of you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Return Type Included in Method Signature ?