Ques. What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package? 1. public 2. abstract 3. protected 4. default access
Ans: (4) default access
why not also protected. When we are talking about same package both default access and protected are equally restrictive. It's only when we talk abt 2 different packages, protective is less restrictive than default. But ques explicitly states same package, so shouldn't it be both default and protected. please suggest.
I think that they, by asking you to pick out the most restrictive modifier, are looking for the modifier which has the most restrictive properties OVERALL which will still fulfill the requirement of allowing you to access it from within the same class. In a comparison of overall properties, default is more restrictive than protected.
I agree with you that the question is somewhat ambiguous though, and that your interpretation is fully correct. I just don't think that it?s what they meant when they wrote it.