0
Polymorphism question
did i understand polymorphism correctly? if i use pokemon as reference(Pokemon p1=new Pikachu(); & Pokemon p2=new charmander();),i can access any pikachu&charmander methods only if the subclasses contain the same method as pokemon class. if i use pikachu as reference ( Pikachu p1=new Pikachu();) i can access all pikachu and pokemon's methods but not charmander's methods https://code.sololearn.com/c0I7Zo8qSeoT/?ref=app
2 Respostas
+ 3
yes that is pretty much it however parent class can only access methods which you have overridden eg
Pokemon p4=new Pikachu();
p4.attack();
This will show an error
0
While some of the words you use aren't what I would use, I believe you understand the concept.