SCJP试题-SCJPMockExam1

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



Q29
Which of these are keywords in Java?

1) default
2) NULL
3) String
4) throws
5) long

Q30
It is desirable that a certain method within a certain class can only be accessed by classes that are defined within the same package as the class of the method. How can such restrictions be enforced?

1) Mark the method with the keyword public.
2) Mark the method with the keyword protected.
3) Mark the method with the keyword private.
4) Mark the method with the keyword package.
5) Do not mark the method with any accessibility modifiers.

Q31
Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?

CODE FRAGMENT A:
int[][] tab = {
{ 0, 0, 0 },
{ 0, 0, 0 }
};

CODE FRAGMENT B:
int tab[][] = new int[4][];
for (int i=0; i
CODE FRAGMENT C:
int tab[][] = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
};

CODE FRAGMENT D:
int tab[3][2];

CODE FRAGMENT E:
int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };

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

Q32
What will be the result of attempting to run the following program?

public class Qaa75 {
public static void main(String args[]) {
String[][][] arr = {
{ {}, null },
{ { "1", "2" }, { "1", null, "3" } },
{},
{ { "1", null } }
};
System.out.println(arr.length + arr[1][2].length);
}
}

1) The program will terminate with an ArrayIndexOutOfBoundsException.
2) The program will terminate with a NullPointerException.
3) 4 will be written to standard output.
4) 6 will be written to standard output.
5) 7 will be written to standard output.

Q33
Which expressions will evaluate to true if preceded by the following code?

String a = "hello";
String b = new String(a);
String c = a;
char[] d = { 'h', 'e', 'l', 'l', 'o' };

1) (a == "Hello")
2) (a == b)
3) (a == c)
4) a.equals(b)
5) a.equals(d)

Q34
Which statements concerning the following code are true?

class A {
public A() {}
public A(int i) { this(); }
}
class B extends A {
public boolean B(String msg) { return false; }
}
class C extends B {
private C() { super(); }
public C(String msg) { this(); }
public C(int i) {}
}

1) The code will fail to compile.
2) The constructor in A that takes an int as an argument will never be called as a result of constructing an object of class B or C.
3) Class C has three constructors.
4) Objects of class B cannot be constructed.
5) At most one of the constructors of each class is called as a result of constructing an object of class C.

Q35
Given two collection objects referenced by col1 and col2, which of these statements are true?

1) The operation col1.retainAll(col2) will not modify the col1 object.
2) The operation col1.removeAll(col2) will not modify the col2 object.
3) The operation col1.addAll(col2) will return a new collection object,
containing elements from both col1 and col2.
4) The operation col1.containsAll(Col2) will not modify the col1 object.

视频学习

我考网版权与免责声明

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

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

最近更新

社区交流

考试问答