Question: Your customer is desperate. He owns the program code of a class person as well as a file friends.dat. Friends.dat contains serialized byte sequences of

Your customer is desperate. He owns the program code of a class person as well as a file friends.dat. Friends.dat contains serialized byte sequences of various person objects. Your customer does not know how to "bring the byte sequences back to life" (activated). He wants to know what people are in the friends.dat file and what the friendship relationships between them look like. Your customer knows that the friends.dat file contains a single ArrayList object. Here is the source code of the class Person (in the anonymous default package):

Your customer is desperate. He owns the program code of a class

You get the class Person in the source code as well as the file friends.dat as an attachment to this task. Create a static decode method in the Decode class (in the anonymous default package) that deserializes the file given as the filename parameter and then prints out the friendships in the order they appear in the deserialized ArrayList. The desired output format is as follows (where the file friends.dat contains other than the following personal data): Hans mag Frieda Berta mag Fritz Frieda mag Hans Fritz mag Fritz

1 import java.io.Serializable; 3 public class Person implements Serializable 4 private static final long serialVersionUID1L; private String name; private Person bestFriend; 6 public Person(String name) 9 this.namename; 2 public void setBestFriend (Person friend) i this.bestFriend-friend; 14 public Person getBestFriend() return bestFriend; 18 19 public String getName()[ return name; Override 5 public String toString()5 26 return name "( bestFriend.name+ ")"; 27 28

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!