Marker interfaces in java

Marker interfaces in java

how marker interfaces work?

View Answers

January 19, 2011 at 5:00 PM

Hi Friend,

In java language programming, interfaces with no methods are known as marker interfaces. Marker interfaces are Serializable, Clonable, SingleThreadModel, Event listener. Marker Interfaces are implemented by the classes or their super classes in order to add some functionality.

e.g. Suppose you want to persist (save) the state of an object then you have to implement the Serializable interface otherwise the compiler will throw an error. To make more clearly understand the concept of marker interface you should go through one more example.

Suppose the interface Clonable is neither implemented by a class named Myclass nor it's any super class, then a call to the method clone() on Myclass's object will give an error. This means, to add this functionality one should implement the Clonable interface. While the Clonable is an empty interface but it provides an important functionality.

Example:

interface markerImp {
}

class MarkerTest implements markerImp{
}

public class TestInstanceOf {
public static void main(String []args){
MarkerTest mt = new MarkerTest();
if(mt instanceof markerImp){
System.out.println("True");
}
else{
System.out.println("False");
}
}
}

For more information, visit the following link:

Marker Interface

Thanks


January 19, 2011 at 5:14 PM

By implementing Serializable interface which has no methods and variables, how the class know to save the state of the object?

Ads









Related Tutorials/Questions & Answers:
Marker interfaces in java
Marker interfaces in java  how marker interfaces work
Marker Interface,Java Marker Interface
; In this section we will learn about Interface and Marker Interfaces in Java...); } Marker Interface In java language programming, interfaces with no methods are known as marker interfaces. Marker interfaces
Advertisements
Marker Interface In Java
marker interfaces are used to inform something to Java compiler for adding special...Marker Interface In Java In this section we will read about marker interface in Java. This section will describe you the various aspects of marker interface
java interfaces
java interfaces  sample code for multiple interface   interface A { void test(int i); } interface B { void test(String s); } public class MultipleInterface implements A, B { public void test(int i
difference between marker and tag interface - Java Interview Questions
); } Marker Interface In java language programming, interfaces with no methods are known as marker interfaces. Marker interfaces are Serializable, Clonable, SingleThreadModel, Event listener. Marker Interfaces are implemented by the classes
java interfaces implementation
java interfaces implementation  hai I have defined one inter face like Maths taking methods like add(), sub(), mul()in interface I take different implementation classes for add() method and sub()and mul() when i trying
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
interfaces
& interfaces.   An interface declaration introduces a new reference type whose members are classes, interfaces, constants and abstract methods... to directly implement one or more interfaces, meaning that any instance of the class
Marker interface
Marker interface  what is a marker interface? what is its significance
What are Classes and Interfaces in Java?
In this tutorial we are going to discuss about classes and interfaces in Java... and interfaces concepts in detail. What are classes? Java is Object oriented...) are performed at runtime.   What are interfaces? Interfaces in Java
Marker Interface
Marker Interface  What is the need of Marker Interface?When should we use
What is a Marker Interface?
What is a Marker Interface?   Hi, What is a Marker Interface? thanks
ModuleNotFoundError: No module named 'marker'
ModuleNotFoundError: No module named 'marker'  Hi, My Python... 'marker' How to remove the ModuleNotFoundError: No module named 'marker'... to install padas library. You can install marker python with following command
ModuleNotFoundError: No module named 'magic-marker'
ModuleNotFoundError: No module named 'magic-marker'  Hi, My Python... 'magic-marker' How to remove the ModuleNotFoundError: No module named 'magic-marker' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'trademac-marker'
ModuleNotFoundError: No module named 'trademac-marker'  Hi, My... named 'trademac-marker' How to remove the ModuleNotFoundError: No module named 'trademac-marker' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'trademark-marker'
ModuleNotFoundError: No module named 'trademark-marker'  Hi, My... named 'trademark-marker' How to remove the ModuleNotFoundError: No module named 'trademark-marker' error? Thanks   Hi, In your
Overview of Networking through JAVA,Getting list of Local Interfaces on a machine
Getting list of Local Interfaces on a machine... to find out the total no of list of local interfaces available on a machine. Here... the local interfaces which are instances of NetworkInterface class and displays
EJB Interfaces
EJB Interfaces       Interface in java means a group of related methods with empty bodies. EJB have generally 4 interfaces. These are as follows 1)Remote interface:- Remote interface
EJB Interfaces
EJB Interfaces       Interface in java means a group of related methods with empty bodies. EJB have generally 4 interfaces. These are as follows 1)Remote interface:- Remote interface
ModuleNotFoundError: No module named 'pytest-fixture-marker'
ModuleNotFoundError: No module named 'pytest-fixture-marker'  Hi...: No module named 'pytest-fixture-marker' How to remove the ModuleNotFoundError: No module named 'pytest-fixture-marker' error? Thanks   Hi
ModuleNotFoundError: No module named 'pytest-manual-marker'
ModuleNotFoundError: No module named 'pytest-manual-marker'  Hi...: No module named 'pytest-manual-marker' How to remove the ModuleNotFoundError: No module named 'pytest-manual-marker' error? Thanks   Hi
ModuleNotFoundError: No module named 'pytest-marker-bugzilla'
ModuleNotFoundError: No module named 'pytest-marker-bugzilla'  Hi...: No module named 'pytest-marker-bugzilla' How to remove the ModuleNotFoundError: No module named 'pytest-marker-bugzilla' error? Thanks   Hi
What are Callback interfaces?
What are Callback interfaces?  Hi, What are Callback interfaces? thanks
ModuleNotFoundError: No module named 'interfaces'
ModuleNotFoundError: No module named 'interfaces'  Hi, My Python... 'interfaces' How to remove the ModuleNotFoundError: No module named 'interfaces' error? Thanks   Hi, In your python environment you
java
java  what is marker interface?   Interfaces with no methods is known as marker interfaces. Marker interfaces are Serializable, Clonable, SingleThreadModel, Event listener. Marker Interfaces are implemented
What are the Core interfaces are of Hibernate framework?
What are the Core interfaces are of Hibernate framework?  Hi, What are the Core interfaces are of Hibernate framework? Thanks
interfaces,exceptions,threads
interfaces,exceptions,threads  SIR,IAM JAVA BEGINER,I WANT KNOW THE COMPLETE CONEPTS OF INTERFACES,EXCEPTIONS,THREADS   Interface... class. In java, multiple inheritance is achieved by using the interface
ModuleNotFoundError: No module named 'odoo12-addon-fieldservice-google-marker-icon-picker'
ModuleNotFoundError: No module named 'odoo12-addon-fieldservice-google-marker...: ModuleNotFoundError: No module named 'odoo12-addon-fieldservice-google-marker...;odoo12-addon-fieldservice-google-marker-icon-picker' error? Thanks  
ModuleNotFoundError: No module named 'odoo12-addon-web-widget-google-marker-icon-picker'
ModuleNotFoundError: No module named 'odoo12-addon-web-widget-google-marker...: ModuleNotFoundError: No module named 'odoo12-addon-web-widget-google-marker-icon...;odoo12-addon-web-widget-google-marker-icon-picker' error? Thanks   
ModuleNotFoundError: No module named 'odoo8-addon-contract-recurring-invoicing-marker'
-marker'  Hi, My Python program is throwing following error...-marker' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-contract-recurring-invoicing-marker' error? Thanks   Hi
Hibernate: core interfaces of hibernate framework
Hibernate: core interfaces of hibernate framework  What are the core interfaces of hibernate framework   Most of hibernate based application code deals with following interfaces provided by the Hibernate Core

Ads