• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Question on Access Modifiers

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Sri Jad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..??
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.......
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic