SCJP试题-SCJPMockExam1

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



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();
}

DEFINITION D:
(d) interface D implements I {
void increment();
}

DEFINITION E:
(e) class E implements I {
int value;
public void setValue(int val) { value = val; }
}

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

Q51
Which statements concerning the methods notify() and notifyAll() are true?

1) Instances of class Thread have a method called notify().
2) A call to the method notify() will wake the thread that currently owns the monitor of the object.
3) The method notify() is synchronized.
4) The method notifyAll() is defined in class Thread.
5) When there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.

Q52
Which statements concerning the correlation between the inner and outer instances of non-static inner classes are true?

1) Member variables of the outer instance are always accessible to inner instances, regardless of their accessibility modifiers.
2) Member variables of the outer instance can never be referred to using only the variable name within the inner instance.
3) More than one inner instance can be associated with the same outer instance.
4) All variables from the outer instance that should be accessible in the inner instance must be declared final.
5) A class that is declared final cannot have any inner classes.

Q53
What will be the result of attempting to compile and run the following code?

public class Q6b0c {
public static void main(String args[]) {
int i = 4;
float f = 4.3;
double d = 1.8;
int c = 0;
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2;
System.out.println(c);
}
}

1) The code will fail to compile.
2) 0 will be written to the standard output.
3) 1 will be written to the standard output.
4) 2 will be written to the standard output.
5) 3 will be written to the standard output.

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答