File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question in K&B Book - protected class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question in K&B Book - protected class" Watch "Question in K&B Book - protected class" New topic

Question in K&B Book - protected class

mustafa duran

Joined: Oct 10, 2005
Posts: 14
Hi friends,

the following question comes from K&B SCJP 1.4 book on Chapter 2. I am confused about "protected class" term. Can protected modifier be used for classes? if so what is the reason?

Question No 2 :
Given a method in a protected class, what access modifier do you use to restrict access to
that method to only the other members of the same class?
A. final
B. static
C. private
D. protected
E. volatile
F. default access
Kris Krason

Joined: Aug 05, 2005
Posts: 25
Well, it is possible if it is an inner class.

Kris Krason<br />SCJP1.4 (96%)<br />SCJP1.5 (91%)<br /> <br />See my <a href="" target="_blank" rel="nofollow">Code Complete review</a><br /> <br /><a href="" target="_blank" rel="nofollow">Pseudocode Programming Process</a>
david lightman
Ranch Hand

Joined: Nov 03, 2004
Posts: 82

I thought Classes use default and public,
Members can use all four, public private, protected and default.
[ November 10, 2005: Message edited by: david lightman ]
Patrick Williams
Ranch Hand

Joined: Apr 03, 2005
Posts: 213
I'm not sure if it was captured in the errata and republished, but my copy of K&B states "Given a method in a public class, what access modifier..."
[ November 13, 2005: Message edited by: Patrick Williams ]

Patrick<br /> <br />SCJP/SCWCD/SCBCD/SCDJWS/SCEA<br /> <br />Currently working on:<br />SCJP 6
I agree. Here's the link:
subject: Question in K&B Book - protected class
jQuery in Action, 3rd edition