SCJP Mock Exam 1(3)
添加时间: 2007-9-23 2:34:54 作者: JAVA题库 阅读次数:77 来源: http://www.d9soft.com
4) final public static void main(String [] array)
5) public static void main(String args[])
Q19
Under which circumstances will a thread stop?
1) The method waitforId() in class MediaTracker is called.
2) The run() method that the thread is executing ends.
3) The call to the start() method of the Thread object returns.
4) The suspend() method is called on the Thread object.
5) The wait() method is called on the Thread object.
Q20
When creating a class that associates a set of keys with a set of values, which of these interfaces is most applicable?
1) Collection
2) Set
3) SortedSet
4) Map
Q21
What does the value returned by the method getID() found in class java.awt.AWTEvent uniquely identify?
1) The particular event instance.
2) The source of the event.
3) The set of events that were triggered by the same action.
4) The type of event.
5) The type of component from which the event originated.
Q22
What will be written to the standard output when the following program is run?
class Base {
int i;
Base() {
add(1);
}
void add(int v) {
i += v;
}
void print() {
System.out.println(i);
}
}
class Extension extends Base {
Extension() {
add(2);
}
void add(int v) {
i += v*2;
}
}
public class Qd073 {
public static void main(String args[]) {
bogo(new Extension());
}
static void bogo(Base b) {
b.add(8);
b.print();
}
}
1) 9
2) 18
3) 20
4) 21
5) 22
Q23
Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?
public class Qf575 {
// insert declaration of a native method here
}
1) native public void setTemperature(int kelvin);
2) private native void setTemperature(int kelvin);
3) protected int native getTemperature();
4) public abstract native void setTemperature(int kelvin);
5) native int setTemperature(int kelvin) {}
Q24
How does the weighty property of the GridBagConstraints objects used in grid bag layout affect the layout of the components?
1) It affects which grid cell the components end up in.
2) It affects how the extra vertical space is distributed.
3) It affects the alignment of each component.
4) It affects whether the components completely fill their allotted display area vertically.
Q25
Which statements can be inserted at the indicated position in the following code to make the program write 1 on the standard output when run?
public class Q4a39 {
int a = 1;
int b = 1;
int c = 1;
class Inner {
int a = 2;
int get() {
int c = 3;
// insert statement here
return c;
}
}
Q4a39() {
Inner i = new Inner();
System.out.println(i.get());
}
public static void main(String args[]) {
new Q4a39();
}
}
1) c = b;
2) c = this.a;
3) c = this.b;
4) c = Q4a39.this.a;
5) c = c;
Q26
Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done?
public class Q76a9 {
static String f() {
String a = "hello";
String b = "bye"; // (0)
String c = b + "!"; // (1)
String d = b;
b = a; // (2)
d = a; // (3)
return c; // (4)
}
public static void main(String args[]) {
String msg = f();
System.out.println(msg); // (5)
}
}
1) The line marked (1).
2) The line marked (2).
3) The line marked (3).
4) The line marked (4).
5) The line marked (5).
Q27
Which methods from the String and StringBuffer classes modify the object on which they are called?
1) The charAt() method of the String class.
2) The toUpperCase() method of the String class.
3) The replace() method of the String class.
4) The reverse() method of the StringBuffer class.
上一篇文章: SCJP Mock Exam 1(2) 下一篇文章: SCJP Mock Exam 1(4)
相关文章:

