This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class marked protected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class marked protected" Watch "inner class marked protected" New topic

inner class marked protected

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all!
Marcus Greens mock ( ) has following question:
Question 57)
Which of the following statements are true?
1) Adding more classes via import statements will cause a performance overhead, only import classes you actually use.
2) Under no circumstances can a class be defined with the private modifier
3) A inner class may under some circumstances be defined with the protected modifier
4) An interface cannot be instantiated
It is clear that option 3 is right but what actually means "under some circumstances"? I think I would cut it out.

Antti Barck
It Solutions Consultant, NSD Oy
Snylt Master
Ranch Hand

Joined: Jul 07, 2001
Posts: 55
Take a look at the follwing code.
public class test{

void aMethod(){
class innerClass{
// In a method variables and classes cannot be marked with access modifiers
Correct me if I'm wrong

Preparing for the Java 2 Certification exam
Guoqiao Sun
Ranch Hand

Joined: Jul 18, 2001
Posts: 317
I think "under some circumstance" means sometimes it can be defined as protected. Since for top-level class, we cannnot define it as protected, but for inner class, we might define it as protected.
Correct me if i am wrong.

Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="" target="_blank" rel="nofollow"></a>, Java resource, mock exam, forum
I agree. Here's the link:
subject: inner class marked protected
Similar Threads
Marcus Exam No2 #57
Native Method
can we instantiate interfaces
Marcus Green Exam- On Inner classes
Inner class basics. (Marcus Green's mock exam 2)