Open links in new tab
  1. Marker interface pattern

    Design pattern
  2. A marker interface in Java is an empty interface with no methods or fields, used to tag or mark a class so that the JVM or frameworks can treat it differently at runtime. It acts as metadata to convey special behavior without enforcing method implementation. Common examples include Serializable, Cloneable, and Remote.

    When a class implements a marker interface, it signals to the JVM or APIs that it supports certain capabilities. For example, implementing Serializable tells Java that objects of the class can be converted into a byte stream for storage or transfer.

    Example – Serializable Marker Interface

    import java.io.*;

    class Person implements Serializable {
    String name;
    public Person(String name) {
    this.name = name;
    }
    }

    public class Demo {
    public static void main(String[] args) throws Exception {
    Person p = new Person("John");

    // Serialize
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data.obj"));
    oos.writeObject(p);
    oos.close();

    // Deserialize
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.obj"));
    Person p2 = (Person) ois.readObject();
    ois.close();

    System.out.println("Name: " + p2.name);
    }
    }
    Copied!
  1. Marker Interface in Java - GeeksforGeeks

    Apr 23, 2026 · A Marker Interface in Java is an interface that contains no methods or fields. It is used to mark a class so that the Java runtime or compiler can identify some special behavior or capability of …

  2. Marker Interfaces in Java - Baeldung

    A marker interface is an interface that doesn’t have any methods or constants inside it. It provides run-time type information about objects, so the compiler and JVM have additional information about the object. A marker interface is also called a tagging interface. Though marker interfaces are still in use, they very likely point to a code smell, …
    See more on baeldung.com
    • Published: Feb 7, 2019
    • Marker Interface Pattern in Java: Defining Behavior …

      Explore the Marker Interface pattern in Java, its benefits, real-world examples, and common uses. Learn how to use marker interfaces for metadata and special …

    • What is the use of marker interfaces in Java? - Stack …

      Jan 3, 2010 · In earlier versions of Java, Marker Interfaces were the only way to …

      • Reviews: 1
      • What Are Marker Interfaces in Java? Understanding Their Purpose …

        Jan 16, 2026 · A marker interface is a special type of interface in Java that contains no method declarations. Instead, its sole purpose is to "tag" or "mark" a class as having a specific property, …

      • Marker Interface in Java - Online Tutorials Library

        In Java, an interface without methods, fields, or constants is known as a Marker interface. The Marker interface is also known as the tagged interface, and this …

      • Marker Interfaces in Java: The Most Misunderstood Yet …

        Oct 20, 2024 · What is a Marker Interface? A marker interface, also known as a tagging interface, is an interface that does not contain any methods or …

      • Marker Interface In Java: Serializable And Cloneable

        Apr 1, 2025 · This tutorial explains what is a Marker Interface in Java. It also covers Serialization Deserialization and Cloning in Java with code example.

      • Marker Interfaces in Java: A Comprehensive Guide

        In the world of Java programming, marker interfaces play a crucial role, although they might seem a bit mysterious at first glance. A marker interface is an interface that has no methods defined within it. Its …

      • Marker Interface in Java with Example - javabytechie

        May 28, 2022 · An interface that does not contain any property (fields and methods) is known as Marker Interface in Java. It is also known as a Tagging Interface. The Marker interface provides the run-time …

      • People also ask
        Loading
        Unable to load answer