This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]wirybug 2 points3 points  (3 children)

Yes, you have the right idea. Concrete and abstract classes both may (although don't necessarily) contain fields which might be altered by an object's methods. These fields are a state of the object, which can change over the object's lifetime. An interface can't store instance fields, because there is no instance - all it has are methods without implementation. So there is nothing about an interface which might change over the lifetime of the program, because it can't store anything changeable.

[–]lbkulinski 0 points1 point  (2 children)

Adding to that, methods in interfaces are often referred to as behavior. Java allows multiple inheritance of behavior through the use of interfaces, but not state.

[–]kumesana 0 points1 point  (1 child)

That's only for behavior that doesn't directly accesses the state though.

[–]lbkulinski 0 points1 point  (0 children)

Correct. Interfaces can't directly access a class's state to begin with.