Java Programming Worksheet-3
Java Programming Worksheet-3
WORKSHEET 3
2. Source Code:
import java.io.*;
class Person implements Serializable {
private String name;
private int age;
private String contact;
try {
try {
FileInputStream fileIn = new
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
FileInputStream("person.ser");
ObjectInputStream in = new
ObjectInputStream(fileIn);
deserializedPerson = (Person) in.readObject();
in.close();
fileIn.close();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
if (deserializedPerson != null) {
System.out.println("Deserialized" +
" Person Information:");
System.out.println("Name: " +
deserializedPerson.getName());
System.out.println("Age: " +
deserializedPerson.getAge());
System.out.println("Contact: " +
deserializedPerson.getContact());
}
}
}
3. Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
4. Learning Outcomes
(i) Understand the concept of Java programming.
(ii) Developed problem-solving skills.