Oracle 1Z0-808 Exam (page: 4)
Oracle Java SE 8 Programmer I
Updated on: 29-Aug-2025

Viewing Page 4 of 49

View the exhibit.



Which change enables the code to print the following?
James age: 20
Williams age: 32

  1. Replacing line 5 with public static void main (String [] args) throws MissingInfoException, AgeOutofRangeException {
  2. Replacing line 5 with public static void main (String [] args) throws.Exception {
  3. Enclosing line 6 and line 7 within a try block and adding:
    catch(Exception e1) { //code goes here}
    catch (missingInfoException e2) { //code goes here} catch (AgeOutofRangeException e3) {//code goes here}
  4. Enclosing line 6 and line 7 within a try block and adding:
    catch (missingInfoException e2) { //code goes here} catch (AgeOutofRangeException e3) {//code goes here}

Answer(s): C



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 4 of 49



Share your comments for Oracle 1Z0-808 exam with other users:

Mchal 7/20/2023 3:38:00 AM

some questions are wrongly answered but its good nonetheless
POLAND


Merry 7/30/2023 6:57:00 AM

good questions
Anonymous