black

SCJP程序员认证考试

登录

单项选择题

1. import java.io.*; 
2. public class Foo implements Serializable { 
3. public int x, y; 
4. public Foo( int x, int y) { this.x = x; this.y = y; } 
5. 
6. private void writeObject( ObjectOutputStream s) 
7. throws IOException { 
8. s.writeInt(x); s.writeInt(y) 
9. } 
10. 
11. private void readObject( ObjectInputStream s) 
12. throws IOException, ClassNotFoundException { 
13. 
14. // insert code here 
15. 
16. } 
17. } 
Which code, inserted at line 14, will allow this class to correctly serialize and deserialize?() 

A. s.defaultReadObject();
B. this = s.defaultReadObject();
C. y = s.readInt(); x = s.readInt();
D. x = s.readInt(); y = s.readInt();

相关考题

单项选择题 import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?()

单项选择题 Whencomparingjava.io.BufferedWritertojava.io.FileWriter,whichcapabilityexistsasamethodinonlyoneofthetwo?()

多项选择题 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?()

All Rights Reserved 版权所有©易学考试网(yxkao.com)

备案号:湘ICP备2022003000号-3