|
-
August 15th, 1999, 08:19 PM
#1
private access modifier
Hi,
With the following code I am able to access the private variable of another class.How does this explain data hiding concept.
public class Y extends X
{
public static void main(String[] arg)
{ int val;
X x = new X();
val = x.m1(2);
System.out.println(val);
}
}
class X {
private int y ;
public int m1(int a){
y =a ;
System.out.println("ans=" + y);
return y;
}
}
Thanks,
Deepa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|