----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
Originally posted by Wesley Liu:
Given the following classes and declarations, which of these statements are true?
class A
{
private int i = 10;
public void f( ) { }
public void g( ) { }
}
class B extends A
{
public int i = 20;
public void g( ) {}
}
A a = new A( );
A b = new B( );
Options:
A.System.out.println(b.i); will print out 20
B.System.out.println(b.i); will print out 10
C.None of above
the answer is C, but I donot understand why it is not 20.
[This message has been edited by Wesley Liu (edited May 21, 2001).]
S.R.VenuGopal,<br />Senior Analyst/Programmer,<br />B.E.(EE), GNIIT, SCJP2
S.R.VenuGopal,<br />Senior Analyst/Programmer,<br />B.E.(EE), GNIIT, SCJP2
sona<br />SCJP