单项选择题

10. public class Foo implements java.io.Serializable { 
11. private int x; 
12. public int getX() { return x; } 
12.publicFoo(int x){this.x=x; } 
13. private void writeObject( ObjectOutputStream s) 
14. throws IOException { 
15. // insert code here 
16. } 
17. } 
Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?() 

A. s.writeInt(x);
B. s.serialize(x);
C. s.writeObject(x);
D. s.defaultWriteObject();


您可能感兴趣的试卷

你可能感兴趣的试题

3.多项选择题Which three concerning the use of the java.io.Serializable interface are true?()

A. Objects from classes that use aggregation cannot be serialized.
B. Art object serialized on one JVM can be successfully deserialized on a different JVM.
C. The values in fields with the volatile modifier will NOT survive serialization anddeserialization.
D. The values in fields with the transient modifier will NOT survive serialization anddeserialization.
E. It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable.

6.单项选择题When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two?() 

A. closing the stream
B. flushing the stream
C. writing to the stream
D. marking a location in the stream
E. writing a line separator to the stream

7.多项选择题

10. class MakeFile { 
11. public static void main(String[] args) { 
12. try { 
13. File directory = new File(”d”); 
14. File file = new File(directory,”f”); 
15. if(!file.exists()) { 
16. file.createNewFile(); 
17. } 
18. } catch (IOException e) { 
19. e.printStackTrace 
20. } 
21. } 
22. } 
The current directory does NOT contain a directory named “d.” Which three are true?()

A. Line 16 is never executed.
B. An exception is thrown at runtime.
C. Line 13 creates a File object named “d”.
D. Line 14 creates a File object named “f‟.
E. Line 13 creates a directory named “d” in the file system.
F. Line 16 creates a directory named “d” and a file  “f”  within it in the file system.
G. Line 14 creates a file named "f " inside of the directory named “d” in the file system.

10.多项选择题

public class TestString3 { 
public static void main(String[] args) { 
// insert code here 
System.out.println(s); 
} 
} 
Which two code fragments, inserted independently at line 3, generate the output 4247?()

A. String s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;
B. StringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);
C. StringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);
D. StringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);
E. StringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);