• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

oo concepts

 
maggie karve
Ranch Hand
Posts: 187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
W. Joe Smith
Ranch Hand
Posts: 710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe it has to do with this line:



Since you have a Derived object, whenever you are calling addValue() you are goign to call teh most specific version of that method, in this case being value += 20. Since it is being called twice (once in superclass constructor, once in subclass constructor) the value will be 40.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic