0

So I have been reading this great article about polymorphysm in Java Upcasting and Downcasting in Java and I encounter "automatic downcast during method calls" which the author did not explain in the article but he mentioned its very useful when we want to use polymorphysm.

Anybody can help me understand what it means ?

MohsenFM
  • 129
  • 1
  • 13
  • 1
    Java does not automatically downcast anywhere. Can you any code the author had to illustrate what (s)he meant? Is the author credible? – Bohemian Sep 17 '16 at 00:19
  • 1
    @Bohemian I doubt that the author is credible. See my answer for a best guess as to what the author means. Search for "Polymorphism uses automatic downcast during method calls" inside the linked article to find the relevant paragraph. – Mike Nakis Sep 17 '16 at 00:25
  • Thank you guys. I thought that was a legit article about 'polymorphysm' and I kinda enjoyed it because it was an easy read but I guess you can't trust every article on the internet. – MohsenFM Sep 18 '16 at 11:01

1 Answers1

4

The statement "Polymorphism uses automatic downcast during method calls" is a very unfortunate attempt on behalf of the author to convey the fact that you can invoke "animal.speak();" and the animal will receive the call and process it as a "cat" or "dog" or whatever it is that the animal really is.

So, the author perversely thinks of this as automatic downcasting during a method call: you invoke an animal, and what ends up being invoked is a cat.

You can tell by the drawings that this is not a very high quality tutorial.

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142