2

I'm preparing for java OCA exam, and while running some test, I remarked that an interface/abstract class could be declared with package private access modifier, but not protected even if default access modifier is "strict" than protected.
. here is an example
Example 1

//package 1;
public abstract class T1{..}
// package 2;
public class T2 extends T1{..}


Example 2

//package 1;
abstract class T1{..}
// package 2;
// compiler error 
public class T2 extends T1{..}


Example 3

//package 1;
protected abstract class T1{..} //doesn't work

can anyone explain ?

aName
  • 2,751
  • 3
  • 32
  • 61

0 Answers0