More on Serialization
Explore advanced serialization concepts in Java, including why non-static inner classes shouldn't implement Serializable, the role of serialVersionUID, and how superclass constructors affect serialization. Understand how to manage member object serialization and subclass behavior to ensure robust serialized forms.
We'll cover the following...
We'll cover the following...
1.
Explain the Externalizable interface.
Show Answer
1 / 2
Technical Quiz
1.
Consider the following class setup:
class Course {
String company;
private Course() { }
Course(String company) {
this.company = company;
}
}
class EducativeCourse extends Course implements Serializable {
public EducativeCourse(String authorName) {
super("Educative");
this.authorName = authorName;
}
private String authorName;
}
Can we serialize the class EducativeCourse ?
A.
Yes
B.
No
1 / 1
Technical Quiz
1.
If we make the parameterless constructor of the super class Course public, the subtype EducativeCourse would become serializable. What would be printed from the following sequence:
// 1. Serialize an object of EducativeCourse
// 2. Deserialize the same object back
// 3. Print the company name like so
System.out.println(object.company)
A.
Educative
B.
empty string
C.
null
1 / 1
Non-static nested classes (inner classes) shouldn't implement the
Serializable...