William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Arhaan Singhania wrote:Hi Pinki,
The methods are basically overloaded and choice of which overloaded method to call or the signature depends upon
reference type and signature. If you see the method is taking Mammal reference so it is calling the Mammal eating
Hay. I guess this is the correct answer.
Arhaan
Mezan Shareef wrote:
Arhaan Singhania wrote:Hi Pinki,
The methods are basically overloaded and choice of which overloaded method to call or the signature depends upon
reference type and signature. If you see the method is taking Mammal reference so it is calling the Mammal eating
Hay. I guess this is the correct answer.
Arhaan
Hi Arhaan
I dont see methods overloaded, eat method have only one parameter, they are overridden. but, i think, h is of type mamal, so mamal code is excuted. I did not execute the code though, just guessing.
MySQL Blog
http://mysqlearner.blogspot.com/
Mezan Shareef wrote:
Arhaan Singhania wrote:Hi Pinki,
The methods are basically overloaded and choice of which overloaded method to call or the signature depends upon
reference type and signature. If you see the method is taking Mammal reference so it is calling the Mammal eating
Hay. I guess this is the correct answer.
Arhaan
Hi Arhaan
I dont see methods overloaded, eat method have only one parameter, they are overridden. but, i think, h is of type mamal, so mamal code is excuted. I did not execute the code though, just guessing.
foxy milano wrote:
Mezan Shareef wrote:
Arhaan Singhania wrote:Hi Pinki,
The methods are basically overloaded and choice of which overloaded method to call or the signature depends upon
reference type and signature. If you see the method is taking Mammal reference so it is calling the Mammal eating
Hay. I guess this is the correct answer.
Arhaan
Hi Arhaan
I dont see methods overloaded, eat method have only one parameter, they are overridden. but, i think, h is of type mamal, so mamal code is excuted. I did not execute the code though, just guessing.
hi mezan i think that arhaan is right... if you read katy and bert book about rule of overriding, they said that :"The argument list must exactly match that of the overridden method. If they
don't match, you can end up with an overloaded method you didn't intend"
the problem here is this : Mammel is a parent of Cattle and cattle is the parent of Horse
so Horse inherit all eat() method from Mammel and Cattle
Cattle inherit eat() method from Mammel
so if you call the eat method from Horse object and pass a Cattle or Mammel reference , it will call the Cattle or Mammel eat method because Horse object inherit them.
regards.
SCJP 93%<br />SCWCD 86%<br />SCBCD 92%<br />SCDJWS 95%
Hari Krishna wrote:Hi Mezan,
For Overloaded Method, there will be change in method signature
But in Overriding Method, there won't be any change.
See the below link you can understand easily:
http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Cheers,
Hari krishna
money grubbing section goes here:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|