← Back to libraryQuestion 42 of 273
JavaIntermediate

Marker Interfaces

📖 Detailed Explanation:

A marker interface has no methods or fields. Its only purpose is to 'tag' a class so the JVM or framework treats it specially. Examples: Serializable (marks objects that can be serialized), Cloneable (marks objects that can be cloned), Remote (marks objects that can be accessed remotely in RMI).

🌍 Real-World Example:

A 'Fragile' sticker on a box. The sticker doesn't change the box; it tells the mail carrier (JVM) to handle it with extra care.

🎯 Scenario-Based Interview Question:

Are Marker Interfaces still relevant in modern Java? What's the alternative?