miscellaneous
What are Marker Interfaces and why are they required?
Definition:
An interface with no methods or fields.
Examples:
SerializableCloneableRemote
Purpose:
- They act as tags or "flags" for the JVM or a library.
- For example, if a class implements
Cloneable, it tellsObject.clone()that it is safe to make a field-for-field copy. Without it,CloneNotSupportedExceptionis thrown. - In modern Java, these are often replaced by Annotations, which are more flexible.