Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 12

Consider below code:

What will be the result of compiling and executing Test class?


Options are :

  • An exception is thrown at runtime (Correct)
  • Compilation error
  • [RED, ORANGE]
  • [RED, GREEN]
  • [RED, ORANGE, GREEN]

Answer :An exception is thrown at runtime

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 42

Consider following code snippet:

Location of Exam.java file:

You are currently at Sec07 folder.
D:\WORK\Quiz\Sec07>

Which of the following javac command, typed from above location, will generate Exam.class file structure under classes directory?



Options are :

  • javac classes\ src\com\cher\test\Exam.java
  • Not possible by javac command
  • javac -d classes\ src\com\cher\test\Exam.java (Correct)
  • javac -d classes\ Exam.java

Answer :javac -d classes\ src\com\cher\test\Exam.java

What will be the result of compiling and executing Greetings class?


Options are :

  • Good Morning! null
  • Good Morning! Good Evening! (Correct)
  • null Good Evening!
  • null null

Answer :Good Morning! Good Evening!

Consider below code:

What will be the result of compiling and executing Test class?


Options are :

  • An exception is thrown at runtime
  • [Walnut, Apricot, Date]
  • [Walnut, Apricot, Almond, Date] (Correct)
  • [Walnut, Date]

Answer :[Walnut, Apricot, Almond, Date]

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 14

Consider below code snippet:

Which of the following options, if used to replace /*INSERT*/, compiles successfully?


Options are :

  • List
  • List
  • List
  • List (Correct)
  • Answer :List

    Consider below code:

    What will be the result of compiling and executing Test class?


    Options are :

    • 2020-02-04
    • Compilation error (Correct)
    • Runtime exception
    • 2020-02-03

    Answer :Compilation error

    Consider below code: 

    On execution, does Test class print "HELLO" on to the console?


    Options are :

    • No, HELLO is not printed on to the console (Correct)
    • Yes, HELLO is printed on to the console

    Answer :No, HELLO is not printed on to the console

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 6

    What will be the result of compiling and executing Test class?


    Options are :

    • Hello19
    • Hello10
    • Hello1234 (Correct)
    • Hello 10

    Answer :Hello1234

    Which of the following correctly imports Animal class from com.masaimara package?


    Options are :

    • Import com.masaimara.Animal;
    • import com.masaimara.*; (Correct)
    • import com.masaimara;
    • Import com.masaimara.Animal;

    Answer :import com.masaimara.*;

    Consider below code: 

    What will be the result of compiling and executing Test class?


    Options are :

    • [true] (Correct)
    • An exception is thrown at runtime
    • Compilation error
    • [false]
    • [true, false]

    Answer :[true]

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 5

    What will be the result of compiling and executing Test class?



    Options are :

    • ANY FRUIT WILL DO APPLE MANGO BANANA
    • ANY FRUIT WILL DO
    • MANGO BANANA (Correct)
    • MANGO

    Answer :MANGO BANANA

    Consider below Lambda expression:

    Predicate predicate = s -> true; 

    Which of the lambda expression can successfully replace the lambda expression in above statement?


    Options are :

    • s -> {return true}
    • s -> {return true;} (Correct)
    • s -> {true;}
    • s -> {true}

    Answer :s -> {return true;}

    What will be the result of compiling and executing Test class?


    Options are :

    • Compilation error.
    • 11 : ! (Correct)
    • An exception is thrown at runtime.
    • 11 : s

    Answer :11 : !

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 17

    Which of the following statement is correct for below code?


    Options are :

    • Program compiles and executes successfully but produces no output
    • Infinite loop
    • It will print "Good Morning!" once
    • Compilation error (Correct)

    Answer :Compilation error

    Consider 2 files:



    Currently on executing Test class, output is: [-1000, 539, 0].


    And below blocks:

    1.

    for(Counter ctr : arr) {

        ctr.count = 100;

    }

    2.

    for (Counter ctr : arr) {

        int x = ctr.getCount();

        x = 100;

    }

    3.

    for (Counter ctr : arr) {

        ctr.getCount() = 100;

    }

    4.

    for(Counter ctr : arr) {

        ctr.increase(100 - ctr.count);

    }

    5.

    for (Counter ctr : arr) {

        ctr.increase(100 - ctr.getCount());

    }

    6.

    for(Counter ctr : arr) {

        ctr.increase(-ctr.getCount() + 100);

    }

    7.

    for(Counter ctr : arr) {

        ctr.increase(-ctr.count + 100);

    }


    How many blocks can replace /*INSERT*/ such that output is: [100, 100, 100]?


    Options are :

    • Only Three blocks
    • Only Six blocks
    • Only One block
    • Only Two blocks
    • Only Four blocks
    • All Seven blocks
    • Only Five blocks (Correct)

    Answer :Only Five blocks

    Does below code compile successfully?


    Options are :

    • No
    • Yes (Correct)

    Answer :Yes

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 18

    What will be the result of compiling and executing Test class?


    Options are :

    • 6
    • An exception is thrown at runtime
    • Compilation error
    • 0
    • 4 (Correct)
    • 5

    Answer :4

    What will be the result of compiling and executing Test class?


    Options are :

    • [110, 110]
    • [110]
    • [] (Correct)
    • [110, 110, 110]

    Answer :[]

    What will be the result of compiling and executing Test class?


    Options are :

    • Compilation error
    • 55
    • 24
    • 25 (Correct)

    Answer :25

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 26

    What will be the output of compiling and executing the Test class?


    Options are :

    • x is equal to 2 (Correct)
    • Compilation error
    • Still no idea what x is x is equal to 1
    • Produces no output

    Answer :x is equal to 2

    Which of the following is true for code below?


    Options are :

    • ArrayIndexOutOfBoundsException (Correct)
    • NullPointerException
    • 0
    • Compilation error

    Answer :ArrayIndexOutOfBoundsException

    For the given code:


    Options are :

    • None of the other options.
    • Implementer class declaration is not correct.
    • Method m1() in Implementer class is not implemented correctly. (Correct)
    • interface I01 gives compilation error as method m1 is not public.

    Answer :Method m1() in Implementer class is not implemented correctly.

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 2

    What will be the result of compiling and executing Test class?


    Options are :

    • TWO THREE
    • THREE
    • None of the System.out.println statements are executed
    • ONE THREE
    • Compilation error (Correct)

    Answer :Compilation error

    Consider code of Test.java file:

    Line 5 is giving compilation error as process method is not found.

    Which of the following method definitions, if used to replace /*INSERT*/, will resolve the compilation error?

    Select ALL that apply.


    Options are :

    • private static int[] process(int [] arr, int start, int end) { return null; } (Correct)
    • private static String process(int [] arr, int start, int end) { return null; } (Correct)
    • private static int process(int [] arr, int start, int end) { return null; }
    • private static String[] process(int [] arr, int start, int end) { return null; } (Correct)

    Answer :private static int[] process(int [] arr, int start, int end) { return null; } private static String process(int [] arr, int start, int end) { return null; } private static String[] process(int [] arr, int start, int end) { return null; }

    What will be the result of compiling and executing Test class?


    Options are :

    • 12345678910
    • 1357911
    • 1234567891011
    • 246810
    • 13579 (Correct)

    Answer :13579

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 7

    For the above code, fill in the blank with one option.


    Options are :

    • Error
    • Object
    • RuntimeException
    • Exception (Correct)

    Answer :Exception

    Consider below code of Test.java file: 

    Which of the following statement is true?


    Options are :

    • Four initializer blocks cause compilation error.
    • Three initializer blocks cause compilation error.
    • Only one initializer block causes compilation error. (Correct)
    • Five initializer blocks cause compilation error.
    • Two initializer blocks cause compilation error.

    Answer :Only one initializer block causes compilation error.

    What will be the result of compiling and executing following program?


    Options are :

    • 100, 200
    • 0, 0
    • Compilation Error (Correct)
    • 200, 100

    Answer :Compilation Error

    Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 35

    Consider below code: 

    What will be the result of compiling and executing Test class?


    Options are :

    • An exception is thrown at runtime
    • [Array]
    • [List, Array]
    • [Array, List]
    • [List] (Correct)

    Answer :[List]

    What will be the result of compiling and executing Test class?


    Options are :

    • Point(0, 200)
    • Point(100, 100)
    • Point(200, 200)
    • Point(200, 0)
    • Compilation error (Correct)
    • Point(100, 200)
    • Point(100, 0)

    Answer :Compilation error

    Comment / Suggestion Section
    Point our Mistakes and Post Your Suggestions