I wanted to try and test a lot of things about serialization/deserialization with a made-up code, just for myself. Unfortunately, I got stuck at the very beginning. Here is the code:
import java.io.*;

public class Solution implements Serializable { //

    private int age;
    private int weight;
    private String name;
    private int length;

    public Solution(int age, int weight, String name, int length) {
        this.age = age;
        this.weight = weight;
        this.name = name;
        this.length = length;

    private void writeObject(ObjectOutputStream out) throws IOException {

    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {

    public static void main(String[] args) throws Exception {
        Solution s1 = new Solution(3,6,"Tiger",50);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);

I got this: "NotActiveException: not in call to writeObject" Unfortunately, I couldn't figure out what this means. What I need to do to serialize the s1 object?