SCJP1.5考试题汇总
- 格式:pdf
- 大小:599.79 KB
- 文档页数:138
目录
I. Declarations,Initialization and Scoping ........................................................................................2
II. Flow Control ................................................................................................................................16
III. API Context ................................................................................................................................33
IV. Concurrency ...............................................................................................................................48
V. OOConcepts .................................................................................................................................64
VI. Collections/Generics ................................................................................................................102
VII. Fundamentals .........................................................................................................................123
2
I. Declarations,Initialization and Scoping
1. 声明:类、抽象类、嵌套类、接口和枚举
2. package和import语句(包括import static)
3. 实现或扩展接口、扩展抽象类
4. 静态成员
5. 方法重载(overload)
6. 构造函数
7. 类实例化
8. JavaBean的命名
9. 变成参数列表
______________________________________________________________________________
1. Given the Exhibit:
enum Example { ONE, TWO, THREE }
Which is true?
A. The expressions (ONE == ONE) and ONE.equals(ONE) are both
guaranteed to be true.
B. The expression (ONE < TWO) is guaranteed to be true and
ONE.compareTo(TWO) is guaranteed to be less than one.
C. The Example values cannot be used in a raw java.util.HashMap;
instead, the programmer must use a java.util.EnumMap.
D. The Example values can be used in a java.util.SortedSet, but the
set will NOT be sorted because enumerated types do NOT implement
java.lang.Comparable.
2. Place the lines the correct order to complete the enum.enumElement{
Lince
1st 2st 3st 4st 5st public String info(){return “element”;}
};
FIRE{public String info(){return “Hot”}
EARTH.WIND
}
3
3. Place the elements in order so that resulting Java source file will compile corretly,resultingin a
class called com.sun.cert.AddrressBook.
Code Elemtent
Source File
ArrayList entries;
}
4. Given:
package geometry;
public class Hypotenuse {
public InnerTriangle it = new InnerTriangle();
class InnerTriangle {
public int base;
public int height;
}
}
Which is true about the class of an object that can reference the
variable base?
A. It can be any class.
B. No class has access to base.
C. The class must belong to the geometry package.
D. The class must be a subclass of the class Hypotenuse.
5. Which two classes correctly implement both the java.lang.Runnable and the java.lang.Clonable
interfaces? (Choose two.)
A. public class Session implements Runnable, Clonable {
public void run();
public Object clone();
}
1st
2st
3st
Package com.cn.cert;
Puckage com.sun.
Import java.util..*
Import java.util
Import java.*
Public class AddressBook
4
B. public class Session extends Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { / make a copy */ }
}
C. public class Session implements Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { /* make a copy */ }
}
D. public abstract class Session implements Runnable, Clonable {
public void run() { / do something */ }
public Object clone() { /*make a copy */ }
}
E. public class Session implements Runnable, implements Clonable {
public void run() { / do something */ }
public Object clone() { / make a copy */ }
}
6. Given:
public static void main(String[] args) {
String str = “null’;
if (str == null) {
System.out.println(”null”);
} else (str.length() == 0) {
System.out.println(”zero”);
} else {
System.out.println(”some”);
}
}
What is the result?
A. null
B. zero
C. some
D. Compilation fails.
E. An exception is thrown at runtime.
7. Given:
public class Yippee2 {
static public void main(String [] yahoo) {
for(int x= 1; x
}