Marker interface doesn’t has any thing. It contains only interface declarations, then how it is handled by the JVM for the classes which implements this marker interface?
Can we create any new marker interfaces ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Your question should really be how does the compiler handle marker interfaces, and the answer is: No differently from any other interface. For example, suppose I declare a new marker interface
Foo:… and then declare a class
Barthat implementsFoo:I am now able to refer to an instance of
Barthrough a reference of typeFoo:… and also check (at runtime) whether an object implements
Foo:This latter case is typically the driver behind using marker interfaces; the former case offers little benefit as there are no methods that can be called on
Foo(without first attempting a downcast).