Editorial / Best Answer
dipl. ing. Dan
Some people might get confused by the many posts. The correct answer to the question "can we declare class as protected?" is YES, BUT only as an inner class. A 'normal' class cannot be protected or private.
// 'Normal' class - only default or public allowed
public class ProtectedOrNot {
// Inner class - public, default, protected, private allowed
protected class InnerClass {
}
public static void main(String[] args) {
}
}
Can we declare class as protected?
Editorial / Best Answer
dipl. ing. DanProfile Answers by dipl. ing. Dan Questions by dipl. ing. Dan
Some people might get confused by the many posts. The correct answer to the question "can we declare class as protected?" is YES, BUT only as an inner class. A 'normal' class cannot be protected or private.
// 'Normal' class - only default or public allowed
public class ProtectedOrNot {
// Inner class - public, default, protected, private allowed
protected class InnerClass {
}
public static void main(String[] args) {
}
}
Related Answered Questions
Related Open Questions