Prévia do material em texto
Certified Java Programmer Mock Exam 44
e. Prints: 2,5,9
f. Compile-time Error.
g. Runtime Error.
h. None of the Above.
Question 14
Which of the following statements are true?
a. The compiler will create a default constructor if no other constructor is declared.
b. The default constructor takes no parameters.
c. The default constructor invokes the superclass constructor with no arguments.
d. The default constructor declares Exception in the throws clause.
e. The default constructor is always given the private access modifier.
f. The default constructor is always given the public modifier.
g. The default constructor is always given default package access.
h. None of the above.
Question 15
class C {
public static void main(String[] args) {
int[] a1[] = {new int[]{1,2},new int[]{3,4,5}};
int []a2[] = new int[][]{{1,2},{3,4,5}};
int a3[][] = {{1,2},new int[]{3,4,5}};
System.out.print(a1[0][1]+","+a2[1][0]+","+a3[1][2]);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 14
b. Prints: 16
c. Prints: 1,2,4
d. Prints: 2,3,4
e. Prints: 2,3,5
f. Prints: 2,4,5
g. Compiler Error.
h. Runtime Error.
i. None of the Above.
Question 16
class A {
public static void main(String[] args) {
int[][] a = {{1,2},{3,4,5},{6,7,8,9},{}};
System.out.print(a.length);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: 0
b. Prints: 3
c. Prints: 4
d. Prints: 9
e. Prints: 10
f. Prints: 11
g. Compiler Error.
h. Runtime Error.
i. None of the Above.
Question 17
class A {}
class B {
public static void main(String[] arg) {
A[] a1 = new A[1]; // 1
A[][] a2 = new A[2][1]; // 2
A[][][] a3 = new A[3][3][3]; // 3
System.out.print(a3[2][2][2]); // 4
a1[0] = new A(); // 5
a2[0] = a2[1] = a1; // 6
a3[0] = a3[1] = a3[2] = a2; // 7
System.out.print(a3[2][2][2]); // 8
}
}
What is the result of attempting to compile and run the above program?
a. Prints: null
b. Prints: nullnull
c. Compile-time error at 1.
d. Compile-time error at 2.
e. Compile-time error at 3.
f. Compile-time error at 4.
g. Compile-time error at 5.
h. Compile-time error at 6.
i. Compile-time error at 7.
j. Compile-time error at 8.