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?
thanks.


Source: oop

Leave a Reply