SCJP试题-SCJPMockExam1

来源:java认证发布时间:2012-11-12 12:48:18java认证视频



Q12
What will be written to the standard output when the following program is run?

public class Qd803 {
public static void main(String args[]) {
String word = "restructure";
System.out.println(word.substring(2, 3));
}
}

1) est
2) es
3) str
4) st
5) s

Q13
Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work?

CODE BLOCK A:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
Thread t = new Thread(r);
t.start();

CODE BLOCK B:
Thread t = new Thread() {
public void start() {
Work.doIt();
}
};
t.start();

CODE BLOCK C:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
r.start();

CODE BLOCK D:
Thread t = new Thread(new Work());
t.start();

CODE BLOCK E:
Runnable t = new Runnable() {
public void run() {
Work.doIt();
}
};
t.run();

1) Code block A.
2) Code block B.
3) Code block C.
4) Code block D.
5) Code block E.

Q14
Write a line of code that declares a variable named layout of type LayoutManager and initializes it with a new object, which when used with a container can lay out components in a rectangular grid of equal-sized rectangles, 3 components wide and 2 components high.

Q15
public class Q275d {
static int a;
int b;
public Q275d() {
int c;
c = a;
a++;
b += c;
}
public static void main(String args[]) {
new Q275d();
}
}

1) The code will fail to compile, since the constructor is trying to access static members.
2) The code will fail to compile, since the constructor is trying to use static member variable a before it has been initialized.
3) The code will fail to compile, since the constructor is trying to use member variable b before it has been initialized.
4) The code will fail to compile, since the constructor is trying to use local variable c before it has been initialized.
5) The code will compile and run without any problems.

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答