Skip to main content

1Z0-811 Real Exam Questions

Java Foundations

75 questions available · Page 1 of 8

Updated Exam DumpsVerified AnswersPass Guarantee

Get Complete Exam Dumps
Question 1 Single choice

Which statement is true about exception handling?

  1. A

    At least one catch block must accompany a try statement.

  2. B

    All statements in a try block are executed, even if an exception occurs in the middle of the try block.

  3. C

    At least one statement in a try block must throw an exception.

  4. D

    All catch blocks must be ordered from general to most specific.

Show answer and explanation

Correct answer: D

Explanation

References:
https://www.javatpoint.com/multiple-catch-block-in-java

Question 2 Single choice

Given the code fragment:

What is the result?

  1. A

    [jasmine, rose, lily]

  2. B

    A runtime exception is thrown.

  3. C

    [jasmine, lily, lotus]

  4. D

    [jasmine, rose, lotus, lily]

Show answer and explanation

Correct answer: B

Explanation
Question 3 Single choice

Given the code fragment:

What is the result?

  1. A

    A compilation error occurs at line n1.

  2. B

    Jack

  3. C

    The program prints either Jack or Queen.

  4. D

    Queen

Show answer and explanation

Correct answer: A

Explanation
Question 4 Single choice

Given the code fragment:

Which code fragment, when inserted at line n1, enables it to print Rita is 14 years old?

  1. A

    System.out.println("%s is %d years old" +name+age);

  2. B

    System.out.println("%s is %n years old" name, age);

  3. C

    System.out.printf("%s is %d years old", name, age);

  4. D

    System.out.printf("%s is %n years old", name, age);

Show answer and explanation

Correct answer: C

Explanation
Question 5 Single choice

Given:

What is the output?

  1. A

    1 2 3 aaaa

  2. B

    1 2 aaa

  3. C

    Compilation fails

  4. D

    a

Show answer and explanation

Correct answer: D

Explanation
Question 6 Multiple choice

Which two components can class declarations include?

  1. A

    A list of instance methods

  2. B

    The main method

  3. C

    Interfaces implemented by the class

  4. D

    The public modifier

Show answer and explanation

Correct answers: C, D

Explanation

References:
https://docs.oracle.com/javase/tutorial/java/javaOO/classdecl.html

Question 7 Single choice

Given the code fragment:

Which for loop statement can be used to print 135?

  1. A

    for(int idx = 1; idx < arr.length; idx+=2) {
    System.out.print (arr[idx]);
    }

  2. B

    for(int idx = 1; idx < arr.length?; idx++) {
    System.out.print (arr[idx++]);
    }

  3. C

    for(int idx = 0; idx < arr.length; idx++) {
    System.out.print (arr[idx]);
    }

  4. D

    for(int idx = 0; idx < arr.length; idx+=2) {
    System.out.print (arr[idx]);
    }

Show answer and explanation

Correct answer: D

Explanation
Question 8 Multiple choice

Identify two Java reserved words.

  1. A

    array

  2. B

    true

  3. C

    this

  4. D

    exception

  5. E

    string

Show answer and explanation

Correct answers: B, C

Explanation

References:
https://www.computerhope.com/jargon/j/java_reserved_words.htm

Question 9 Single choice

Given the contents of the Test.java file:

What is the result?

  1. A

    200 : 400

  2. B

    A compilation error occurs at line n1.

  3. C

    A compilation error occurs at line n2.

  4. D

    100 : 400

Show answer and explanation

Correct answer: C

Explanation
Question 10 Single choice

Given the code fragment:

What is the output?

  1. A

    8

  2. B

    3

  3. C

    0

  4. D

    A compilation error occurs.

Show answer and explanation

Correct answer: C

Explanation