Serialization

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

What is object serialization?

The process of flattening objects so they can be stored on disk or transmitted through a data stream.

2
New cards

How do you make a class serializable?

By implementing the java.io.Serializable interface.

3
New cards

What is the role of ObjectOutputStream in serialization?

It is used to serialize objects and write them to an OutputStream using the method writeObject(Object obj).

4
New cards

How do you de-serialize an object?

By using ObjectInputStream to read the object from an InputStream with the method readObject().

5
New cards

What happens if you try to serialize a class without implementing Serializable?

The object will not be serialized or de-serialized.

6
New cards

Are static properties serialized?

No, static properties are not saved during serialization.

7
New cards

What is an InvalidClassException in serialization?

An exception thrown when the serial version UID of a class does not match between serialization and de-serialization.

8
New cards

What is the serial version UID?

A 64-bit secure hash of a class’s full description used for versioning during serialization and de-serialization.

9
New cards

How can you manually set the serial version UID of a class?

By defining a private static final long serialVersionUID field with a specific value.

10
New cards

What is meant by object graph serialization?

Serialization must preserve the entire object graph, serializing all objects reachable from the original object.

11
New cards

What does the Externalizable interface allow you to do?

It allows developers to specify which fields of an object should be serialized, using the methods writeExternal and readExternal.

12
New cards

What does the transient keyword do in serialization?

It prevents a specific field from being serialized.

13
New cards

What is the default process for de-serialization?

It involves reading the class type from the stream, constructing an object from its highest serializable superclass, and reading field states from the stream.

14
New cards

How can you customize serialization and de-serialization?

By implementing the writeObject and readObject methods in the class.