aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on Access Modifiers 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 on Access Modifiers" Watch "Question on Access Modifiers" New topic
Author

Question on Access Modifiers

Sri Jad
Ranch Hand

Joined: Apr 25, 2005
Posts: 49
Iam referring to the question from K&B book(for version 1.4 - page 134) ..

1. 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?
A. public
B. abstract
C. protected
D. synchronized
E. default access

and the given answer is E(page 141)

But as per the same book(127)

There are three access modifiers: public, protected, and private.
There are four access levels: public, protected, default, and private.

As per the question its access modifier , but not acces level..in that case answer should be C..Some one correct me if i'm wrong
vignesh hariharan
Ranch Hand

Joined: Jun 23, 2005
Posts: 77
ya even i got this same doubt.. but after seeing the answer as E then i thought that default has less scope than protected.. so i thought default is put up as the answer for that.. i am also not sure.. pls ranchers help us...


Regards,
vignesh
Sri Jad
Ranch Hand

Joined: Apr 25, 2005
Posts: 49
i thought that default has less scope than protected..


default access level is definitely most restrictive(has less scope) than protective , but the question was most restrictive access modifier not most restrictive access level
vignesh hariharan
Ranch Hand

Joined: Jun 23, 2005
Posts: 77
ya i guessed the answer since that default access has less scope than protected... and wat is that u have a deal with most restrictive access modifier and most restrictive access level ??? access modifiers gives the access levels right??? then wats the problem..??
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
1. 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?


The default (package protected) access modifier has the same visiblity as "protected" access modifier.

But, if the question ask for "class" access modifer for the top level class, then only "default" is right.
Sri Jad
Ranch Hand

Joined: Apr 25, 2005
Posts: 49
1. 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?


For a given(or specified) package both protective access modifier and dafualt access level have the same scope .the difference comes only when other packages comes into picture.So our question is limited to the same package and as per the its access modifier not access level.

This is what i understood , still i may be wrong some where.
K Vidhyakar
Ranch Hand

Joined: Jul 10, 2005
Posts: 68
hi,
I had the same doubt . bcos default is not an access modifier. its the access level that we get when we dont include any modifiers.
In the question i was asked about the most restrictive access modifiers and not access levels. So according to me the answer is protected. but i have attended many mock exam and they to say the same answer as default for similar question.
I have appeared the exam and i got the same question and i have put the default as the answer . it was correct.i have secured 96 % in the exam.

So the anwer is Default. more suggestion are welcome.......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Access Modifiers
 
Similar Threads
Question in K&B Book - protected class
doubt in access modifier
Access modifier to an Abstract Class constructor
Roundup Game Question #118
access modifier for an abstract class