Free Oracle 1Z0-808 Exam Braindumps (page: 6)

Given the code fragment:

public static void main(String[] args) {
int iArray[] = {65, 68, 69};
iArray[2] = iArray[0];
iArray[0] = iArray[1];
iArray[1] = iArray[2];
for (int element : iArray) {
System.out.print(element + " ");
}

  1. 68, 65, 69
  2. 68, 65, 65
  3. 65, 68, 65
  4. 65, 68, 69
  5. Compilation fails

Answer(s): B



Given:

public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case "7": System.out.print("Uranus");
case "6": System.out.print("Saturn");
case "1": System.out.print("Mercury");
case "2": System.out.print("Venus");
case "3": System.out.print("Earth");
case "4": System.out.print("Mars");
case "5": System.out.print("Jupiter");
}
}
}

Which two modifications, made independently, enable the code to compile and run?

  1. Adding a break statement after each print statement
  2. Adding a default section within the switch code-block
  3. Changing the string literals in each case label to integer
  4. Changing the type of the variable day to String
  5. Arranging the case labels in ascending order

Answer(s): A,C

Explanation:

The following will work fine:
public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case 7: System.out.print("Uranus"); break;
case 6: System.out.print("Saturn"); break;
case 1: System.out.print("Mercury"); break;
case 2: System.out.print("Venus"); break;
case 3: System.out.print("Earth"); break;
case 4: System.out.print("Mars"); break;
case 5: System.out.print("Jupiter"); break;
}
}
}



Given:


What is the result?

  1. true:true
  2. true:false
  3. false:true
  4. false:false

Answer(s): C



Given:

  1. Option A
  2. Option B
  3. Option C
  4. Option D

Answer(s): B



Viewing page 6 of 60
Viewing questions 21 - 24 out of 245 questions



Post your Comments and Discuss Oracle 1Z0-808 exam prep with other Community members:

1Z0-808 Exam Discussions & Posts