SCJP Mock Exam 1(6)
添加时间: 2007-9-23 2:39:04 作者: JAVA题库 阅读次数:48 来源: http://www.d9soft.com
public void f() {
a = 0;
b = 0;
int[] c = { 0 };
g(b, c);
System.out.println(a + " " + b + " " + c[0] + " ");
}
public void g(int b, int[] c) {
a = 1;
b = 1;
c[0] = 1;
}
public static void main(String args[]) {
Qcb90 obj = new Qcb90();
obj.f();
}
}
1) 0 0 0
2) 0 0 1
3) 0 1 0
4) 1 0 0
5) 1 0 1
Q45
Which statements concerning the effect of the statement gfx.drawRect(5, 5, 10, 10) are true, given that gfx is a reference to a valid Graphics object?
1) The rectangle drawn will have a total width of 5 pixels.
2) The rectangle drawn will have a total height of 6 pixels.
3) The rectangle drawn will have a total width of 10 pixels.
4) The rectangle drawn will have a total height of 11 pixels.
Q46
Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?
import java.awt.*;
public class Q1e65 {
public static void main(String args[]) {
Window win = new Frame();
Button but = new Button("button");
// insert code fragment here
win.setSize(200, 200);
win.setVisible(true);
}
}
1) win.setLayout(new BorderLayout()); win.add(but);
2) win.setLayout(new GridLayout(1, 1)); win.add(but);
3) win.setLayout(new BorderLayout()); win.add(but, BorderLayout.CENTER);
4) win.add(but);
5) win.setLayout(new FlowLayout()); win.add(but);
Q47
Which method implementations will write the given string to a file named "file", using UTF8 encoding?
IMPLEMENTATION A:
public void write(String msg) throws IOException {
FileWriter fw = new FileWriter(new File("file"));
fw.write(msg);
fw.close();
}
IMPLEMENTATION B:
public void write(String msg) throws IOException {
OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream("file"), "UTF8");
osw.write(msg);
osw.close();
}
IMPLEMENTATION C:
public void write(String msg) throws IOException {
FileWriter fw = new FileWriter(new File("file"));
fw.setEncoding("UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATION D:
public void write(String msg) throws IOException {
FilterWriter fw = FilterWriter(new FileWriter("file"), "UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATION E:
public void write(String msg) throws IOException {
OutputStreamWriter osw = new OutputStreamWriter(
new OutputStream(new File("file")), "UTF8"
);
osw.write(msg);
osw.close();
}
1) Implementation A.
2) Implementation B.
3) Implementation C.
4) Implementation D.
5) Implementation E.
Q48
Which are valid identifiers?
1) _class
2) $value$
3) zer@
4) ¥ngstr
5) 2muchuq
Q49
What will be the result of attempting to compile and run the following program?
public class Q28fd {
public static void main(String args[]) {
int counter = 0;
l1:
for (int i=10; i<0; i--) {
l2:
int j = 0;
while (j < 10) {
if (j > i) break l2;
if (i == j) {
counter++;
continue l1;
}
}
counter--;
}
System.out.println(counter);
}
}
1) The program will fail to compile.
2) The program will not terminate normally.
3) The program will write 10 to the standard output.
4) The program will write 0 to the standard output.
5) The program will write 9 to the standard output.
Q50
Given the following interface definition, which definitions are valid?
interface I {
void setValue(int val);
int getValue();
}
DEFINITION A:
(a) class A extends I {
int value;
void setValue(int val) { value = val; }
int getValue() { return value; }
}
DEFINITION B:
(b) interface B extends I {
void increment();
}
DEFINITION C:
(c) abstract class C implements I {
int getValue() { return 0; }
abstract void increment();
上一篇文章: SCJP Mock Exam 1(5) 下一篇文章: SCJP Mock Exam 1(7)
相关文章:
相关软件:

