How can you declare i so that it is not visible outside the package 'test'. package test; class Test { XXX int i; /* lot of code */ } Private; Protected ; Public; No access modifier; Friend THE ANSWER IS : Private they say that it is not explicitly said that it has to be accessible from the package too. Do they ask such questions in the real exam ???
bill bozeman
Ranch Hand
Joined: Jun 30, 2000
Posts: 1070
posted
0
The real exam is more clear with what they expect. You will get questions like these, but they will say what is the least restrictive access modifier you can give if you don't want "i" to be seen outside of the package test. Which would be "no access modifier" which I think the exam sometimes says something like, leave it as it is or don't do anything. For the question above, I like the "no access modifier" answer better. Private will work, but as you pointed out, "no access modifier" would work also. Bill