Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to tackle ambiguous questions like these ?

 
Shailendra Guggali
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic