+ 6

What is the transitive nature of Polymorphism ?

If possible, relate with Java.

22nd Dec 2018, 1:29 AM
Aaron Stone
Aaron Stone - avatar
2 ответов
+ 8
Polymorphism can mean a lot of things, but you probably mean this: class A { } class B extends A { } class C extends B { } now you can do A thing = new C(); So, `C` can change its shape to look like another class (so it's polymorphic), and you can cast `C` to `A` even though it doesn't directly inherit from it. It still works because inheritance is transitive (B extends A, C extends B, therefor C automatically extends A). If you read that sentence in a tutorial somewhere you probably don't need to worry about it. Lots of big words but it is not important when learning about polymorphism. I'm not sure it even makes sense when you are talking about other kinds of polymorphism.
22nd Dec 2018, 1:45 AM
Schindlabua
Schindlabua - avatar
+ 5
Thanks !! Schindlabua
22nd Dec 2018, 5:43 AM
Aaron Stone
Aaron Stone - avatar