nerdexam
Oracle

1Z0-829 · Question #19

1Z0-829 Question #19: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #19. The question stem and answer options stay visible for context.

Using Java I/O API

Question

Given: import java.io.Serializable; public class Software implements Serializable { private String title; public Software(String title) { this.title = title; } System.out.print("Software "); public String toString() { return title; } } public class Game extends Software { private int players; public Game(String title, int players) { super(title); this.players = players; } System.out.print("Game "); public String toString() { return super.toString() + " " + players; } } import java.io.*; public class AppStore { public static void main(String[] args) { Software s = new Game("Chess", 2); try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("game.ser"))); out.writeObject(s); } catch (Exception e) { System.out.println("write error"); } try { ObjectInputStream in = new ObjectInputStream(new FileInputStream("game.ser"))); s = (Software)in.readObject(); } catch (Exception e) { System.out.println("read error"); } System.out.println(s); } } What is the result?

Options

  • ASoftware Game Chess 0
  • BSoftware Game Software Game Chese 2
  • CSoftware game write error
  • DSoftware Game Software Game chess 0
  • ESoftware Game Chess 2
  • FSoftware Game read error

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Instance initializer blocks#Serialization/Deserialization#Inheritance#Method overriding
Full 1Z0-829 Practice