Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about dynamic binding

 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My puzzles about the following example:
class Base {
void speak() { /*
System.out.println("Base"); /*
} /*
}
class Sub extends Base {
void speak() {
System.out.println("Sub");
}
}
public class Test9{
public static void main(String argv[]){
Base b = new Sub();
b.speak();
}
}
It shows "Sub" when run it. why?
Is it result of "dynamic binding"?
Thanks.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi roger
that is a result of dynamic binding. u r correct.
regards
maulin
 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,Vasavada.
How can I find some help infor or learning materials about Java Dynamic binding, I really wanna know more about such subject.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can check out this
Javaranch Campfire Stories
This should also give you a hint about late binding
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic