File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from JQPlus :: Please help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from JQPlus :: Please help." Watch "Question from JQPlus :: Please help." New topic

Question from JQPlus :: Please help.

Purvesh Vora
Ranch Hand

Joined: Dec 10, 2003
Posts: 47
Consider this class:
class A
private int i;
public void modifyOther(A a1)
a1.i = 20; //1
State whether the following statememnt is true or false:
At //1 a1.i is valid.

Select 1 correct option.
a True
b False

The answer is True. How?? Its compiling fine.
Please explain in details
Thanks & Regards,
Rama Kumar PV

Joined: Dec 26, 2003
Posts: 26
The private keyword means that no one can access that member except the methods of that class. So, a private modifier can only curb the member access from external classes and not to the members within including the inner classes and other methods.
For example, If you create another class B with a private member j in it and instantiate it in class A, you will not be able to access j from class A where as you will be able to access i from within A from all the methods.
I agree. Here's the link:
subject: Question from JQPlus :: Please help.
jQuery in Action, 3rd edition