Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

An instance method defined in a subclass overrides another instance method in the superclass when:

  • Both have the same name
  • Number and type of parameters is same
  • Return type is same

...

Wiki Markup
Technically, a {{private}} method cannot be hidden or overridden. There is no requirement that {{private}} methods with the same signature in the subclass and the superclass, bear any relationship in terms of having the same return type or {{throws}} clause, the necessary conditions for _hiding_. \[[JLS 2005|AA. Bibliography#JLS 05]\]. Consequently, there may be no _hiding_ when the methods have different return types or {{throws}} clauses.

...

Confusing overriding and hiding can produce unexpected results.

Rule Guideline

Severity

Likelihood

Remediation Cost

Priority

Level

MET11-J

low

unlikely

medium

P2

L3

...