Referring to the scenario above, which one of the methods of "Foo" is accessible to class "Bar"?

Choice 1

Method a
Choice 2

Method b
Choice 3

Method c
Choice 4

Method d
Choice 5

Method e

I think its either answer a or b:confused:

07-28-2007, 02:57 PM

brianhks

Only B is accessible to the Bar class. The other methods have what is called package scope. Look here

07-28-2007, 03:11 PM

cruxblack

Access modifier
- private = available only inside it's own class
- default (no modifier) = available inside it's own class and subclasses residing in the same directory only
- protected = available inside it's own class and subclasses anywhere
- public = available publically, no limitation

Foo methods that are accessible to the Bar class are
a aren't accessible, since it's access modifier are default n bar located in another directory
b are accessible
c aren't accesible, its private
d aren't accesible, synchronized aren't an access modifier, its used for thread synchronization, the access modifier for the method are default
e aren't available, having a default modifier

I hope this isn't some kinda homework :p
But if i were supposed to pick one, i'll pick the one with the less limitation, choice 2 ==> b
Hope this helps :D

07-30-2007, 07:11 AM

money123

thankyou so much....
this is not a homework but a test in which i appeared...
so was confused with my answer......
but now clarified.....txx:) :)