webpersistence
webpersistence

Reputation: 904

Do subclasses need to implement Cloneable?

Do subclasses of a class which implements Cloneable need also implement it explicitly?

I read some discussions about this (Do subclasses inherit interfaces?) but the answers are not very clear.

Upvotes: 1

Views: 208

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201537

No. Subclasses will inherit interfaces that their superclasses implement, and thus implicitly also implement the interface. However, it is arguably a better practice to explicitly enumerate the interfaces any given class implements.

See also What does it mean to “program to an interface”?

Upvotes: 2

Related Questions