• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Is Return Type Included in Method Signature ?

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, this is not valid. Return type has to be the same.
 
vijay saraf
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all of you.
 
This tiny ad is wafer thin:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic