beginnerOOP & Core Syntax

What is a marker interface in Java? Give an example.

A marker interface has no methods or fields at all — its only purpose is to 'tag' a class so that other code (often via instanceof or reflection) can check for that tag and change behavior accordingly. Serializable and Cloneable are classic examples — implementing them signals intent to the JVM without requiring any method implementation (annotations have largely replaced this pattern in modern Java).

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to What is the difference between Array and ArrayList?← Back to all Core Java questions