1z0-808 | 10 Tips For Improve 1z0-808 practice test


Q61. Which two are valid array declaration? 

A. Object array[]; 

B. Boolean array[3]; 

C. int[] array; 

D. Float[2] array; 

Answer: A,C 

Q62. Given the code fragment: 

What is the result? 

A. 1:2:3:4:5: 

B. 1:2:3: 

C. Compilation fails. 

D. An ArrayoutofBoundsException is thrown at runtime. 

Answer:

Q63. Given the code fragment: 

StringBuilder sb = new StringBuilder ( ) ; 

Sb.append (“world”); 

Which code fragment prints Hello World? 

A. sb.insert(0,"Hello "); 

System.out.println(sb); 

B. sb.append(0,"Hello "); 

System.out.println(sb); 

C. sb.add(0,"Hello "); 

System.out.println(sb); 

D. sb.set(0,"Hello "); 

System.out.println(sb);D 

Answer:

Explanation: The java.lang.StringBuilder.insert(int offset, char c) method inserts the string representation of the char argument into this sequence. The second argument is inserted into the contents of this sequence at the position indicated by offset. The length of this sequence increases by one.The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence. 

Reference: Java.lang.StringBuilder.insert() Method 

Q64. Given the definitions of the MyString class and the Test class: 

What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q65. Given the code fragment: 

What could expression1 and expression2 be, respectively, in order to produce output –8, 16? 

A. + +a, - -b 

B. + +a, b- -

C. A+ +, - - b 

D. A + +, b - -

Answer:

Q66. Given the fragment: 

What is the result? 

A. 13480.0 

B. 13480.02 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:

Q67. Given the code in a file Traveler.java: 

And the commands: 

Javac Traveler.java 

Java Traveler Java Duke What is the result? 

A. Happy Journey! Duke 

B. Happy Journey! Java 

C. An exception is thrown at runtime 

D. The program fails to execute due to a runtime error 

Answer:

Q68. Given the class definitions: 

And the code fragment of the main() method, 

What is the result? 

A. Java Java Java 

B. Java Jeve va 

C. Java Jeve ve 

D. Compilation fails 

Answer:

Q69. Given the code fragment: 

What is the result if the integer aVar is 9? 

A. 10 Hello World! 

B. Hello Universe! 

C. Hello World! 

D. Compilation fails. 

Answer:

Q70. Given the code fragment: 

public class Test { 

public static void main(String[] args) { 

boolean isChecked = false; 

int arry[] = {1,3,5,7,8,9}; 

int index = arry.length; 

while ( <code1> ) { 

if (arry[index-1] % 2 ==0) { 

isChecked = true; 

<code2> 

System.out.print(arry(index]+", "+isChecked)); 

Which set of changes enable the code to print 1, true? 

A. Replacing <code1> with index > 0 and replacing <code2> with index--; 

B. Replacing <code1> with index > 0 and replacing <code2> with --index; 

C. Replacing <code1> with index > 5 and replacing <code2> with --index ; 

D. Replacing <code1> with index and replacing <code2> with --index ; 

Answer:

Explanation: 

Note: Code in B (code2 is --index;). also works fine.