• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Binding Problem  RSS feed

 
Tommy Green
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning, can someone please tell me why does this return the string "Person" twice(i.e. the Student.getInfo() is not called)?
Sorry about that

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited your code to introduce indentation and formatting. Unformatted code is not easy to read nor understand.

Coming back to the question.
Have you learnt about scope? What does private mean?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because the getInfo() method is private. Private methods are not inherited and cannot be overridden in subclasses.
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you think you are overriding a method, always add the @Override to the overriding method.
That way, if you have made any errors like this, the compiler will tell you about them, rather than you having to wait until you run the program to find there is a problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!