Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hashcode

 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tell me wether the



is the valid override of


and also please explain why



thanks in advance
 
Henry Wong
author
Marshal
Pie
Posts: 20997
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First, I am assuming you are referring to the hashCode() method... you may be referring to a method of your own and not the Object's hashCode() method, but I'm guessing not.


Yes. It's a valid override. You can have the subclass version be synchronized, while the superclass version is not. The subclass version will be executed.

Henry
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell whether this applies to every overriding case...........
like




whether all these are valid override.........also whether it breaks any OOPs principles.......or everything is fine..........with it....
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
phil sohar wrote:please tell whether this applies to every overriding case...........
like




whether all these are valid override.........also whether it breaks any OOPs principles.......or everything is fine..........with it....


Don't you try it?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is valid for every case
 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:Yes it is valid for every case


thanks for clearing my doubt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic