Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Porblem on class scope

Posted on 2002-05-28
11
Medium Priority
?
206 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
11 Comments
 
LVL 92

Accepted Solution

by:
objects earned 150 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Technology Partners: 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!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

916 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