Marker Interface in Java (Tutorial) e.g. Serialization, Remote

preview_player
Показать описание
Serializable in Serialization
and Remote In RMI

Interface without any Declaration

Subscribe to the channel and learn Programming in easy way.

Рекомендации по теме
Комментарии
Автор

A marker interface is like a special label that we can put on a class in Java to tell the system something about it. Just like how we use labels to tell us what's in a box or what type of food is in a container, we can use a marker interface to tell Java something special about a class.

For example, if we have a class that we want to be able to make a copy of, we can add a marker interface called Cloneable to the class. This tells Java that it's okay to make a copy of the class. Similarly, if we have a class that we want to be able to save to a file or send over the internet, we can add a marker interface called Serializable to the class. This tells Java that the class can be saved or sent.



In general, marker interfaces are useful when we want to attach metadata to a class that cannot be expressed using other means, such as by adding methods or fields to the class. By implementing a marker interface, a class can signal to other parts of the system that it has some special behavior or properties that should be taken into account.

VipulTyagi-qp
Автор

What a hardwork naveen just am comparing the same with current videos of your channel.. Thanks for your all the videos..

satheeshguru
Автор

Naveen Sir really you are awesome i don't know to to say thanks to you for explaning because my current project is completely based on core of core java and you help me an lot thanks by heart.

manashranjan
Автор

Thank you Navin Bhai, It's really helpful 🎉

ThaneshwarSahu-lcov
Автор

Very simple explanation on User Defined Marker interface.Thanks a lot

npmca
Автор

sir, when do we go for marker interface in real tym projects?

nishantpandey
Автор

Can you please explain me the real time example where exactly we need to write custom marker interface. I mean where exactly interface "p" should be considered ( from your example in video) .

stephent
Автор

Hi Navin Sir...
Sir I like your all video..I am a beinner and yr video help me alot...
Sir I have a one request to U... Plz gave us some practicals knwlege..plz

asifrizvi
Автор

i got it....suppose i implement serializable which is a marker classes which implement serializable for them jvm has separate logic and it checks using instanceOf method if the class has implemented it then it will undergo the jvm's that separate "X" process else if instanceOf gives false regular process

RaviKumar-vkib
Автор

sir, thank you very much.
your tutorials are realy usefull and helpfull.

barenmandal
Автор

Sar why u will not call Overriding method

debasishsethi
Автор

Hi Navin, can you please give another practical and logical use of marker interface?

Blackhat
Автор

Hi Navin,

I have a doubt, you check for the demo class whether to provide permission and corresponding used show()  but in Serialization we never check for anything, why the need of Marker interface in serialization

divyamalhotra
Автор

Sir as we have used marker interface which has blank declarations in it.So sir can we use an class with blank declarations in it and use instanceof operator to assign permission

AshishSingh-sptq
Автор

Let me contribute few point on Interface use .

If we know "ONLY" the  requirements not bothering about Implementation ..it means  how the implementation will be give OR can be different  with respect of the USER I/O .

EXP: Servlet Interface 
because there we have certain method with returns . so implementation can be differ with user I/O.

same activity can be achieve with "CLASS" but classes does not provide the multiple Inheritance with generic method. so best option is to use Interface.

samoperand
Автор

Good example. But when implement say Serialization we don't check like if instance of Serialization to this. Do we?

AnupSingh
Автор

My Understandings
Marker Interface is the gives permissions to jvm to perform respective tasks with the object

sureshrayudu
Автор

Hi sir...y we need permission actually we can print as obj.show() why we are giving permissions

jagankumar
Автор

I doesn't see use of marker interface from your example. If you don't implement marker interface and check if object is instance of class D then also permission can be checked.

parikhsagar
Автор

Hey Naveen.

why cant we call the show method on object of demo class.like obj.show();

you should give clear cut example, I did not satisfied with your explanation.

nallabathunisuryanarayanareddy
welcome to shbcf.ru