Új hozzászólás Aktív témák

  • g4dg3t

    senior tag

    SCJP-s tesztsorokat nezegetek par napja. Van par elmeroggyant pelda :)
    Egyik kedvencem:

    import java.io.*;

    class Player {
    Player() {
    System.out.print("p");
    }
    }

    class CardPlayer extends Player implements Serializable {
    CardPlayer() {
    System.out.print("c");
    }

    public static void main(String[] args) {
    CardPlayer c1 = new CardPlayer();
    try {
    FileOutputStream fos = new FileOutputStream("play.txt");
    ObjectOutputStream os = new ObjectOutputStream(fos);
    os.writeObject(c1);
    os.close();
    FileInputStream fis = new FileInputStream("play.txt");
    ObjectInputStream is = new ObjectInputStream(fis);
    CardPlayer c2 = (CardPlayer) is.readObject();
    is.close();
    } catch (Exception x) {
    }
    }
    }

    What is the result?
    A). pc
    B). pcc
    C). pcp
    D). pcpc
    E). Compilation fails
    F). An exception is thrown at runtime

    Futtatas es kis guglizas utan egyertelmu, de a vizsgan papir+ceruza komboval egy ilyen kerdest tuti bebuknek. Kivancsi vagyok mit szoltok ehhez.

Új hozzászólás Aktív témák

Hirdetés