Solved

Porblem on class scope

Posted on 2002-05-28
11
204 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: 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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

623 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