Flag Interface?

  I heard about Flag interfaces ,which does not have any methods in them.What is their significane.

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are a few interfaces called as Marker Interfaces(FlagInterfaces) which do not have any methods in them.

Serializable is one such interface. what it does is instructs teh compiler & then teh run time environment to perform a certain operation. In case of serializable all the vraiables , objects are serialized(convereted to bytes) & can be used by ObjectInout/output streams for their purposes.

Remote is another marker interface in the java.rmi package which qualifies the interface as a remote object.


An interface may be defined as the contract that must be executed by implementators.

Flag interface have no implementation but they have specific importance in implementing them.

First one consider the Serialization interface.

You have to make a difference between serializable and non serializable.


By executing a contract.

Now Serializable contract will distinguish the the serializable and non serializable objects .

And Serializable may proudly say that they are Serializable since they have implemented the contract "Serializable".

IN this purpose , no need of methods to distiguish. If You provide the methos, you have to implement them.

But here Just to distinguish two objects, why introducing again unnecessary methods and implement it?.
So no methods.

But any how by implementing that interface, Serializable interfaces have executed the contract.

Same is true for Remote.

Beacuse you have to distinguish the Remote interface and Ordinary interface.

That's why they are implemnting Remote interface.

In this case also providing methods is meaning less.

Take another example of JSDK2.0

Since each service method is a thread, user has to take care of Concurrent access to shared resources in running servlet which will create multiple threads for multiple requests by calling service method (or any doPost or doGet ).

Then Sun introduced SingleThreadModel.

By implementiing that interface, service method of servlet take care of synchronization of resources among multiple threads.

Here also no special behaviour is needed to distinguish between SingeThread and MultipleThreads running. That's why no method in tht interface.

Best of luck

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ngijaneAuthor Commented:
          Thanks for the info..I got it ngijane.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.