Wednesday, January 1, 2014

Java Interview Questions - 3 - Serialization

With Java comes the concept of Serialization, multi-threading, exception handling, Collections, annotation etc. So, it is always better to brush up your skills.
I am here going to touch up some of them.

What is serialization in Java ?
Serialization is the most basic form of data persistence and transfer.
What do you mean by data persistence ?
In its basic sense, data persistence refers to make an object available even after the execution of a program is complete and main memory is cleared.


Why do we need that ?
System can not be always available and even if it is although, memory has limitation to store data in it. Even if we agree on a larger main memory option, it is expensive.


Where do we store data if not in main memory ?
Preferably in secondary memory or disk.


Isn't disk access costly in terms of processing and time ?
Of course, it is. Disk read-write requires more processing than main memory processing but it is cost effective in a whole.


OK, so how about data transfer ?
Yeah, Serialization also helps in data migration in point to point communication over the network. The data can be read as in Input Stream from the network sockets and can be reformed to an object.

Is it always better to store or transfer the data ? What about banking security related information ?
No, it is not always a better choice to store or transfer data over network or in the disk.


Isn't it a flaw ?
No, never. Everything in this world has its own pros and cons. So does have Serialization as well. While storing or transferring an object is a choice, there can be scenarios where some part of it can freely be not stored or transferred. The choice depends on the developer to partially or fully store or transfer an object.


Moving forward, what about the usage of serialization?
RMI calls, distributed computing environment extensively use serialization to interact withing VMs.


How to use serialization in Java ?
The most simplest form of using serialization is to simply implement the java.lang.Serializable marker interface, additionally you can write your own readObject() and writeObject() to perform custom serialization or deserialization.


Deserialization, what is that ?
Deserialization is the reverse process of reconstructing the saved or transferred object back into main memory for further processing


If you are able to relate your knowledge with these articles, would you like to share them in your networks ?


Prev
Palash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti KunduPalash Kanti Kundu

No comments:

Post a Comment