I have seen general discussions on OOP and Java with the statement “polymorphism is just a bottom-up method call.” It is not clear to me how is it so. An example would help a lot.
I have seen general discussions on OOP and Java with the statement polymorphism is
Share
Consider method
foo()that is present inTopbut can be also inMiddleorBottom. If you have object declared as typeTopYou can always call method
foo()on it. However,objmay be of typeBottomas well, so in polymorphic case you will callfoo()onBottomand ifBottomdoes not havefoo()you call it onMiddleand ifMiddledoes not have it, you call it onTop.So your method call goes from
BottomtoTopin a way…