Here’s the code I’m using:
public class Ser implements Serializable {
int x,y;
String name;
public Ser(int a, int b, String c) {
x=a;
y=b;
name = c;
}
}
import java.io.*;
public class testSer {
public static void main(String[] args) {
FileOutputStream testStream = new FileOutputStream("serText.ser");
ObjectOutputStream testOS = new ObjectOutputStream(testStream);
Ser objTest = new Ser(1,2, "Nikhil");
testOS.writeObject(objTest);
testOS.close();
}
}
Here are the errors I’m receiving:
I’ve created the *.ser file manually in the folder(although the book says compiler automatically creates one) but the problem still persists.
RELP!

You’re not dealing with IOException. You need to either catch it or throw it explicitly.
or
This is all a consequence of Java having checked exceptions, of which IOException is one.
For your purposes, the second is probably fine since an IO failure can’t really be recovered from. In larger programs, you’ll almost certainly want to recover from transient IO failures and thus the first would be more appropriate.