SCJP试题-SCJPMockExam1

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



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.
5) The length() method of the StringBuffer class.

Q28
Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?

class A {}
class B extends A {}
class C extends A {}
public class Q3ae4 {
public static void main(String args[]) {
A x = new A();
B y = new B();
C z = new C();
// insert statement here
}
}

1) x = y;
2) z = x;
3) y = (B) x;
4) z = (C) y;
5) y = (A) y;

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答