How does the computer call a method in a class Rat (which inherits from Animal) if all I have is an Animal pointer? (Don't answer as a user. How does it work technically.)
Here Animal is Parent class and You have the pointer for the class Animal so you can create Object for class Rat and assign that object to the pointer and cal the method in the class RAT. But here the condition is method which your are calling must present in Animal class as abstract or normal method than only you can call using Animal Pointer This is called Dynamic Polymorphism. Otherwise we can't call
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME
Get Answers For Free
Most questions answered within 1 hours.