Saturday, 9 March 2013

MCQ #1

Question) Methods which are marked protected can be accessed only by classes within the same package

Options)
  • True
  • False
Answer) Flase

Explanation) I would recommend go through the post on Access Modifiers in Java Tutorials section.If a member (be it a member variable or a member function) is defined to be protected then it is accessible by members in same class, in same package and also in all the sub classes of class in which the protected member is defined. So it is not just the same package.Hence answer is False.

No comments:

Post a Comment

t> UA-39527780-1 back to top