Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class  RSS feed

 
Sunita Vontel
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see the ollowing code
/CODE
public class C {
int i =1;
public void foo() {
System.out.println("C foo()");
}
public static void main(String args[])
{
new D().run(new D());
}
}
class D extends C {
int i =2;
public void foo() {
System.out.println("D foo()");
}
public void run(C ac)
{
System.out.println(ac.i);
foo();
}
}
the result is 1 D foo().
Can somebode explain me how is it 1.I thought it should be 2 D foo().

[This message has been edited by Sunita Vontel (edited August 31, 2000).]
[This message has been edited by Sunita Vontel (edited August 31, 2000).]
 
Sandeep Potnis
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at
this thread and this one too
 
Sunita Vontel
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sandeep
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!