Which of these is an interface for control over serialization and Deserialization Mcq?
View Discussion Show Improve Article Save Article View Discussion Improve Article Save Article Externalization serves the purpose of custom Serialization, where we can decide what to store in stream. // to read object from stream void readExternal(ObjectInput in) // to write object into stream void writeExternal(ObjectOutput out) Key differences between Serializable and Externalizable
Below is the example for Externalization- Java
Output: Default Constructor called The original car is: Name: Shubham Year: 1995 Age: 10 The new car is: Name: Shubham Year: 1995 Age: 10 In the example, the class Car has two methods- writeExternal and readExternal. So, when we write “Car” object to OutputStream, writeExternal method is called to persist the data. The same applies to the readExternal method. This article is contributed by Shubham Juneja. If you
like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks. What is serialization and deserialization in serialization and deserialization?Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object. The byte stream created is platform independent.
Which interface is used for serialization?Serializability of a class is enabled by the class implementing the java. io. Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized.
Which of the following methods is used to avoid serialization and deserialization?Correct Option: D. writeObject() and readObject() methods should be implemented to avoid Java serialization.
What is true about Serializable interface in Java Mcq?Explanation: Serializable interface does not have any method. It is also called a marker interface.
|