If I have a class, class Animal.
And I have a class Dog and a class Cat both inheriting Animal.
Cat can call methods inside Animal. But can Cat call methods of Dog?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The methods defined in a superclass are accesible to any subclass. But “sister” classes cannot access the (private) methods of one another.
So if your classes
CatandDoginherit fromAnimal, then bothCatandDogobjects can call methods fromAnimal, but they cannot (must not) access the methods of each other.