
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What is marker or tagged interfaces in Java
The most common use of extending interfaces occurs when the parent interface does not contain any methods. For example, the MouseListener interface in the java.awt.event package extended java.util.EventListener, which is defined as −
Example
package java.util; public interface EventListener {}
An interface with no methods in it is referred to as a tagging interface. There are two basic design purposes of tagging interfaces −
Creates a common parent
As with the EventListener interface, which is extended by dozens of other interfaces in the Java API, you can use a tagging interface to create a common parent among a group of interfaces. For example, when an interface extends EventListener, the JVM knows that this particular interface is going to be used in an event delegation scenario.
Adds a data type to a class
This situation is where the term, tagging comes from. A class that implements a tagging interface does not need to define any methods (since the interface does not have any), but the class becomes an interface type through polymorphism.
- Related Articles
- What is a marker or tagged interface in Java?
- What is the use of marker interfaces in Java?
- What is the purpose of interfaces in java?
- What are nested interfaces in Java?
- Interfaces in Java
- Marker interface in Java
- What are the SAM Interfaces in Java?
- What is the difference between Externalizable and Serializable interfaces in Java?
- What is the difference between interfaces and abstract classes in Java?
- Marker interface in Java programming.
- What are the in-built functional interfaces in Java?
- How abstraction is achieved using interfaces in Java?
- Functional Interfaces in Java Programming
- Evolution of interfaces in Java
- Tagged Template Literals in JavaScript
