Well sure! Let’s assume that you have in interface IMyCollection
. It has a method boolean isMutable()
.
Now you have two classes, class MyMutableList
and class MyImmutableList
, which both implement IMyCollection
. Each of them would override the instance method isMutable()
, with MyMutableList
simply returning true
and MyImmutableList
returning false
.
isMutable()
in both classes is an instance method that (1) does not use instance variables, and (2) does not affect instance state. However, due to constraints in the language (it’s impossible to override static methods), this design is the only practical one.
Also, I would like to clear up a misconception (as @manouti did as well): non-static methods aren’t instance because they use any instance variables or affect instance state; they’re instance methods because they were defined that way (without the static
keyword), and thus have an implicit this
parameter (which, in languages like Python, is actually explicit!).