Is protected method in super class visible in sub class in a different package? [duplicate]
This question already has an answer here: What is the difference between public, protected, package-private and private in Java? 25 answers It seems very silly, but I am really confused. Please see below code: package com.one; public class SuperClass { protected void fun() { System.out.println("base fun"); } } ---- package com.two; import com.one.SuperClass; public class SubClass extends SuperClass{ public void foo() { SuperClass s = new SuperClass(); s.fun(); // Error Msg: Change visibility of fun() to public } } I have read from oracle doc and here as well, that protected members are visible