Java Reference
In-Depth Information
11. this.salary = salary;
12. this.id = id;
13. }
14.
15. public static void main(String [] args)
16. throws IOException {
17. Employee e = new Employee(“Jim”, 100.0F, 44);
18. FileOutputStream fs =
19. new FileOutputStream(“e.ser”);
20. new ObjectOutputStream(fs).writeObject(e);
21. }
22. }
which one of the following statements is true?
A.
A new file named e.ser is created and contains a serialized Employee object.
B.
The private fields of the Employee object are not serialized.
C.
Line 3 generates a compiler error.
D.
Line 20 generates a compiler error.
E.
Line 20 throws a NotSerializableException.
15.
Given the following code:
5. java.io.Console out = System.console();
6. String s = out.readPassword(“%s”, “Enter a password: “);
7. System.out.println(“You entered “ + s);
which of the following statements are true? (Select two.)
A.
Line 5 generates a compiler error.
B.
Line 6 generates a compiler error.
C.
Line 7 generates a compiler error.
D.
The out reference on line 5 may be null.
E.
The readPassword method does not use a format specifier.
16.
What is the result of the following program?
1. import java.io.*;
2.
3. public class SerializeA {
4. public static void main(String [] args) throws
5. IOException, ClassNotFoundException {
6. A ref = new A(12);
Search WWH ::
Custom Search