ssd3 Multiple-Choice Quiz 1

来源:互联网 发布:淘宝 手机店 推荐 编辑:程序博客网 时间:2024/06/06 10:43
1.
Which method must exist in every Java application?


(a) main
(b) paint
(c) begin
(d) init

 

Answera

每个Java application 里面都必定含有main函数,否则程序无法运行。

 



2.

Which of the following is the string concatenation operator in Java?



(a) +
(b) ^
(c) &
(d) ++

 

Answera

连接两个string的操作符自然是“+”。

 



3.

Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement?

  1. It does not incur run-time overhead.
  2. It can be used to import multiple packages with a single statement.
  3. It can be used to import multiple classes with a single statement.


(a) I and III only
(b) III only
(c) I only
(d) I, II, and III

 

Answera

I. import的包在编译时就被导入参与编译并参与运行,而不会跳过编译直接在运行时空降。

III. *”替代了某包某父类的所有子类,如:import java.io.*; 

 



4.

A difference between the methods print and println of the class java.io.PrintWriter is that



(a) print inserts a new line at the beginning of its output, but println does not
(b) println appends a new line to the end of its output, but print does not
(c) println inserts a new line at the beginning of its output, but print does not
(d) print appends a new line to the end of its output, but println does not

 

Answerb

println相当于在print输出的语句后加一个换行(/n)。

 



5.

What will be output when the following Java program segment is executed?

   int x = 5;   int y = 2;   System.out.println(x + y);


(a) 7
(b) 5 2
(c) 5+2
(d) 52

 

Answera

+”连接两个数字则直接输出运算结果。



6.
What is the right way to handle abnormalities in input on Java?


(a) By handling these problems by providing exception handlers
(b) By writing while loops to guard against bad input
(c) By using the class FileFilter which gracefully filters out bad input data
(d) By always specifying the throws clause in every method header where file I/O is performed

 

Answera

通过提供异常处理来解决问题。

 



7.

All Java exception classes are derived from the class



(a) java.lang.Throwable
(b) java.lang.Error
(c) java.io.IOException
(d) java.lang.RuntimeException

 

Answera

java.lang.Throwable是所有异常的父类;而java.io.IOException只是输入输出异常的父类。

 



8.
According to Javadoc convention, the first sentence of each Javadoc comment should be


(a) an @version tag
(b) the order of lines is not important
(c) an @author tag
(d) a summary sentence of the declared entry

 

Answerd

Javadoc注释开头是概述部分。

 



9.

According to the document entitled Code Conventions for the Java Programming Language, file suffixes used by Java software include which of the following?

  1. .obj
  2. .class
  3. .h


(a) I and III only
(b) II and III only
(c) I and II only
(d) II only

 

Answerd

.obj 目标文件     .h 头文件(java中没有头文件一说)

所有以文本方式存在的.java文件在编译时自动生成.class文件参与运行。

 



10.

A stack trace is



(a) a sequence of method calls
(b) only available through a typical debugger's step into feature
(c) a fatal error that causes a typical debugger to terminate
(d) a list of variables allocated on a program's stack

 

Answera

堆栈跟踪是指函数调用的顺序。