Solved

Porblem on class scope

Posted on 2002-05-28
11
199 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 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now