Visibility of a method in JAVA [duplicate]

This question already has an answer here:

I am blocking on this question :
Is every instance of Y able to call the method aMethod() of every other instance of Y.
The answer I found is NO.

    package a; 
    class X{ 
    protected void aMethod()
    { } 

    package b; 
class Y extends X
    { }

Can you explain to me why?

Source: oop

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.