Solved

Porblem on class scope

Posted on 2002-05-28
11
203 Views
Last Modified: 2010-03-31
Let A represent the access scope of a protected field in a Java class and B represent the access scope of a package-scoped field in that class. Which of the following best represents the relationship between A and B?

 A is a subset of B
 A is a superset of B
 A is equal to B
 (A union B) is not equal to (A intersection B)
 There is no relation between A and B

please help me out
0
Comment
Question by:Shantanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 7041089
Probably: A is a superset of B
0
 
LVL 7

Expert Comment

by:yoren
ID: 7041102
Scope of A: protected fields are accessible by any class that extends the base class. The extending class can be but does not have to be in the same package as the base class.

Scope of B: package-scoped, or "default" variables, are only accessible by classes in the same package.

A is _not_ a subset of B
A is _not_ a superset of B
A is _not_ equal to B

(A union B) is any class in the same package or extending the class. (A intersection B) is just the classes within the same package that extend B.

So, the following assertion is true:

 (A union B) is not equal to (A intersection B)
0
 
LVL 92

Expert Comment

by:objects
ID: 7041161
Isn't (A union B) is not equal to (A intersection B)
Really the same as A not equal to B.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 7041165
> Scope of A: protected fields are accessible by any class
> that extends the base class. The extending
> class can be but does not have to be in the same package
> as the base class.

They are also visible from all classes in the same package.

0
 
LVL 7

Expert Comment

by:yoren
ID: 7041169
Hehe, that's true. The last option also makes no sense. Either A = B or A != B. I consider those both relations.
0
 
LVL 7

Expert Comment

by:yoren
ID: 7041177
>They are also visible from all classes in the same package.

Wow, I never knew that, but I just verified it. In my opinion this is not how it should be, but this isn't something that's going to change.

In this case, however, it doesn't change the answer, as A still differs from B.
0
 
LVL 7

Expert Comment

by:yoren
ID: 7041185
...but yes, A is also a superset of B
0
 
LVL 7

Expert Comment

by:yoren
ID: 7041186
geeze, I sure wish you could revise comments. What a mess I've made :)
0
 

Expert Comment

by:tjo
ID: 7058551
Since when has this become a homework help site? ;P
0
 
LVL 35

Expert Comment

by:girionis
ID: 8798375
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to objects@idg

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question