SCJP试题-SCJPMockExam1

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



Q36
Which statements concerning the relationships between the following classes are true?

class Foo {
int num;
Baz comp = new Baz();
}
class Bar {
boolean flag;
}
class Baz extends Foo {
Bar thing = new Bar();
double limit;
}

1) A Bar is a Baz.
2) A Foo has a Bar.
3) A Baz is a Foo.
4) A Foo is a Baz.
5) A Baz has a Bar.

Q37
Which statements concerning the value of a member variable are true, when no explicit assignments have been made?

1) The value of an int is undetermined.
2) The value of all numeric types is zero.
3) The compiler may issue an error if the variable is used before it is initialized.
4) The value of a String variable is "" (empty string).
5) The value of all object variables is null.

Q38
Which statements describe guaranteed behavior of the garbage collection and finalization mechanisms?

1) Objects are deleted when they can no longer be accessed through any reference.
2) The finalize() method will eventually be called on every object.
3) The finalize() method will never be called more than once on an object.
4) An object will not be garbage collected as long as it is possible for an active part of the program to access it through a reference.
5) The garbage collector will use a mark and sweep algorithm.

Q39
Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?

CODE FRAGMENT A:
public static void main(String args[]) {
if (args.length != 0)
System.out.println(args[args.length-1]);
}

CODE FRAGMENT B:
public static void main(String args[]) {
try { System.out.println(args[args.length]); }
catch (ArrayIndexOutOfBoundsException e) {}
}

CODE FRAGMENT C:
public static void main(String args[]) {
int ix = args.length;
String last = args[ix];
if (ix != 0) System.out.println(last);
}

CODE FRAGMENT D:
public static void main(String args[]) {
int ix = args.length-1;
if (ix > 0) System.out.println(args[ix]);
}

CODE FRAGMENT E:
public static void main(String args[]) {
try { System.out.println(args[args.length-1]); }
catch (NullPointerException e) {}
}

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

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答