Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-28-2007, 09:30 AM
Member
 
Join Date: Jul 2007
Posts: 11
money123 is on a distinguished road
confused with protected qualifier.....plz solve this query...
Class "Foo" resides in package "com.foo" and contains
methods with the following declarations:

a. final String getName()
b. protected final String getDescription()
c. private String getCode()
d. synchronized String getFilename()
e. String getID()

Class "Bar" extends "Foo" and resides in package
"com.foo.bar"

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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-28-2007, 03:57 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Only B is accessible to the Bar class. The other methods have what is called package scope. Look here
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-28-2007, 04:11 PM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
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
But if i were supposed to pick one, i'll pick the one with the less limitation, choice 2 ==> b
Hope this helps

Last edited by cruxblack : 07-28-2007 at 04:15 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-30-2007, 08:11 AM
Member
 
Join Date: Jul 2007
Posts: 11
money123 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading URLs Protected with HTTP Authentication Java Tip java.net 0 04-07-2008 08:58 PM
A great doubt in Java Applet,will u solve it!! anithababu Java Applets 6 01-27-2008 02:20 PM
Help mi solve my error Deon New To Java 3 01-11-2008 06:26 AM
Cannot solve the coding problem of my assignment elimmom New To Java 3 08-13-2007 12:33 PM
help with protected method in vector class katie Advanced Java 1 08-06-2007 11:59 PM


All times are GMT +3. The time now is 08:57 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org