技术开发 频道

SCJP认证套题解析(6)

【IT168 技术文档】

  51、Which is not a method of the class InputStream?
 
  A. int read(byte[])
 
  B. void flush()
 
  C. void close()
 
  D. int available()
 
  答案 B
 
  题目:下面哪个不是InputStream类中的方法
 
  这个题目没有什么好说的,要求熟悉java API中的一些基本类,题目中的InputStream是所有输入流的父类,所有要很熟悉,参看JDK的API文档。方法void flush()是缓冲输出流的基本方法,作用是强制将流缓冲区中的当前内容强制输出。
 
  52、Which class is not subclass of FilterInputStream?
 
  A. DataInputStream
 
  B. BufferedInputStream
 
  C. PushbackInputStream
 
  D. FileInputStream
 
  答案 D
 
  题目:哪个不是FilterInputStream的子类。
 
  此题也是要求熟悉API基础类。Java基础API中的FilterInputStream 的已知子类有:BufferedInputStream, CheckedInputStream, CipherInputStream, DataInputStream, DigestInputStream, InflaterInputStream, LineNumberInputStream, ProgressMonitorInputStream, PushbackInputStream 。
 
  53、Which classes can be used as the argument of the constructor of the class FileInputStream?
 
  A. InputStream
 
  B. File
 
  C. FileOutputStream
 
  D. String
 
  答案 BD
 
  题目:哪些类可以作为FileInputStream类的构造方法的参数。
 
  此题同样是要求熟悉基础API,FileInputStream类的构造方法有三个,可接受的参数分别是:File、FileDescriptor、String类的一个对象。
 
  54、Which classes can be used as the argument of the constructor of the class FilterInputStream?
 
  A. FilterOutputStream
 
  B. File
 
  C. InputStream
 
  D. RandomAccessFile
 
  答案 C
 
  题目:哪些类可以作为FilterInputStream类的构造方法的参数。
 
  FilterInputStream的构造方法只有一个,其参数是一个InputStream对象。
 
  55、Given the following code fragment:
 
  1) switch(m)
 
  2) { case 0: System.out.println("case 0");
 
  3) case 1: System.out.println("case 1"); break;
 
  4) case 2:
 
  5) default: System.out.println("default");
 
  6) }
 
  Which value of m would cause "default" to be the output?
 
  A. 0
 
  B. 1
 
  C. 2
 
  D. 3
 
  答案 CD
 
  题目:给出下面的代码片断m为哪些值将导致"default"输出。

  此题考察switch语句的用法,switch的判断的条件必须是一个int型值,也可以是byte、short、char型的值,case中需要注意的是一个case后面一般要接一个break语句才能结束判断,否则将继续执行其它case而不进行任何判断,如果没有任何值符合case列出的判断,则执行default的语句,default是可选的,可以没有,如果没有default而又没有任何值匹配case中列出的值则switch不执行任何语句。

0
相关文章