Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:08:36+00:00 2026-05-24T21:08:36+00:00

Possible Duplicates: marker interface What is the purpose of a marker interface? I know

  • 0

Possible Duplicates:
marker interface
What is the purpose of a marker interface?

I know what is marker interface – An interface with no methods.
Example: Serializable, Remote, Cloneable.

I am wondering what is the purpose of marker inteface. This is my understanding:-

Basically it is just to identify the special objects from normal objects. Like in case of serialization , objects that need to be serialized must implement serializable interface and down the line writeObject() method must be checking somewhere if it is a instance of serializable or not. As far as i think ,Thats the only purpose for which writeObject using interface serializable(marker interface). Right? or jvm provides some extra functionality too on the basis of serializable interface?

Similar kind of logic is true for cloneable interface.

Now lets see how it is useful.

Lets say in a application we have 1000 value objects.We want to serialize only 100 specific objects . Now JDK has said that programmer role is just to mark the object as special with marker interface in this case its serializable interface.Now JDK will take care of that which object to serialize or not?

Yes we could achieve this kind of behaviour with some kind of bollean flag . but that
would be a bad approach.

Similarily we can say in case of user defined marker interface , we can distinguish special objects with help of marker interface.Like we can use instance of operator to determine if it is a instance of that particular interface . If yes proceed in case of No throw some exception.

Please let if above understanding is correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:08:37+00:00Added an answer on May 24, 2026 at 9:08 pm

    Your understanding is correct. The marker interface also defines a type. It can thus be used in method signatures. For example, Hibernate’s Session.get() method takes a Serializable as argument. It avoids passing a primary key that would not be serializable as argument.

    Note that Cloneable is, retrospectively, seen as a bad design choice.

    Serializable could certainly have been implemented with an annotation if those had existed when serialization was implemented.

    Marker interfaces are, most of the time, an anti-pattern. An interface should define a polymorphic behaviour. A marker interface can be replaced by an annotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What is the purpose of a marker interface? Is it bad practice
Possible Duplicate: marker interface How Marker interface works since it has no methods?
Possible Duplicates: Why is lock(this) {...} bad? In C# it is common to use
Possible Duplicates: Abstract classes vs Interfaces Abstract class and Interface class? Hi All, I
I know why this happens and I want to find a workaround it. Example:
Possible Duplicates: How does this JavaScript/JQuery Syntax work: (function( window, undefined ) { })(window)?
Possible Duplicate: Serializable Inheritance Is serialization inheritable? Example: [Serializable] class A { } class
Possible Duplicate: How to disable Mobile Data on Android I know that this is
Possible Duplicates: C++0X when? When will C++0x be finished? When will C++0x be released?
Possible Duplicates: What is the best approach for a Java developer to learn C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.