How Java serialization works interview

preview_player
Показать описание


Free Download Java Interview Book. All The Best.

What is Java Serialization ? [Java interview Question ]

Java provides a mechanism, called object serialization where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type and the types of data stored in the object.

After a serialized object has been written into a file, it can be read from the file and deserialized that is, the type information and bytes that represent the object and its data can be used to recreate the object in memory.

Most impressive is that the entire process is JVM independent, meaning an object can be serialized on one platform and deserialized on an entirely different platform.

Classes ObjectInputStream and ObjectOutputStream are high-level streams that contain the methods for serializing and deserializing an object.

The ObjectOutputStream class contains many write methods for writing various data types, but one method in particular stands out:
public final void writeObject(Object x) throws IOException
The above method serializes an Object and sends it to the output stream. Similarly, the ObjectInputStream class contains the following method for deserializing an object:

public final Object readObject() throws IOException,
ClassNotFoundException
This method retrieves the next Object out of the stream and deserializes it. The return value is Object, so you will need to cast it to its appropriate data type.

Primary purpose of java serialization is to write an object into a stream, so that it can be transported through a network and that object can be rebuilt again.

How do you serialize?

When you want to serialize an object, that respective class should implement the marker interface serializable. It just informs the compiler that this java class can be serialized. You can tag properties that should not be serialized as transient.
Комментарии
Автор

Thanks for the feedback..I will try to zoom in future vidoes, ,
There is nothing called neg comment .... you are helping us to improve...Thanks

InterviewDOT
Автор

thanks for the feedback, will surely consider.Thanks.

InterviewDOT
Автор

hi thanks for the feedback, in my later videos ..i had increased the volume, please watch other videos as well.thanks happy learning :)

InterviewDOT
Автор

I like that you speak quickly and don't take much time to give instructions.
this is the first video in weeks that I didn't have to watch at 3x speed

Akashascosset
Автор

Thanks a lot for the feedback... if you have java interview questions please post here.. i will try to answer thanks...Pralay Biswas..

InterviewDOT
Автор

Thanks a lot for the feedback - InterviewDot - Job Portal

InterviewDOT
Автор

great job. but please zoom the code while writing

nskarsri
Автор

Thanks you very much. This is very helpful

csureshbabu
Автор

not trying to leave a neg comment but can u try zooming the videos when u code?

ErlWable
Автор

Pls Zoom the code and be little bit louder

prabhakarj
Автор

It would be great, if you could provide serial numbers to the videos Abi - a lil difficult to find what comes after what. P.S. You may connect with me at linkedIn dot com slash in slash pralaybiswas. Would be glad to keep in touch :)
Keep up the good job :)

pralaybiswas