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

What is true about the following code? (Select 1 option.)


Options are :

  • B. The class ShoeFactory has three overloaded constructors, two user-defined constructors, and one default constructor.
  • A. The class ShoeFactory has a total of two overloaded constructors. (Correct)
  • D. The addition of the following constructor will increment the number of constructors of the class ShoeFactory to 3: private ShoeFactory (Shoe arg) {}
  • C. The class ShoeFactory will fail to compile.

Answer :A. The class ShoeFactory has a total of two overloaded constructors.

What is the output of the following code? (Choose one)


Options are :

  • The code prints Camera:Adjust settings manually.
  • The code prints Camera:.
  • The code prints Camera:null.
  • The code fails to compile. (Correct)

Answer :The code fails to compile.

Given the following definition of the class Animal and the interface Jump, select the correct array declarations and initialization (choose all that apply).


Options are :

  • E. Jump[] eJump5 = new Jump()[12];
  • D. Jump[] eJump4 = new Animal[87]; (Correct)
  • C. Jump[] eJump3 = new Jump[10]; (Correct)
  • B. Jump[] eJump2 = new Animal()[22];
  • A. Jump eJump1[] = {null, new Animal()}; (Correct)

Answer :D. Jump[] eJump4 = new Animal[87]; C. Jump[] eJump3 = new Jump[10]; A. Jump eJump1[] = {null, new Animal()};

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

How many times do you think you can shop with the following code (that is, what's the output of the following code)? (Choose one)


Options are :

  • The code fails to compile. (Correct)
  • The code prints enjoying shopping once.
  • The code prints enjoying shopping in an infinite loop.
  • The code prints enjoying shopping twice.

Answer :The code fails to compile.

Examine the following code and select the correct statements (Choose all that apply).


Options are :

  • C. No objects are garbage collected on line 1
  • D. The number of objects that are garbage collected on line 1 is unknown. (Correct)
  • B. At least one object is garbage collected on line 1.
  • E. At least two objects are eligible for garbage collection on line 2. (Correct)
  • A. At least two objects are garbage collected on line 1.

Answer :D. The number of objects that are garbage collected on line 1 is unknown. E. At least two objects are eligible for garbage collection on line 2.

What is the output of the following code? (Choose one)


Options are :

  • m2
  • m3
  • m1
  • The code fails to compile. (Correct)

Answer :The code fails to compile.

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

Given the following code,

what is the output? (Choose one)


Options are :

  • Code fails compilation at line numbers 1, 3, 4, 7.
  • No compilation error—outputs 500:300.
  • Code fails compilation at line numbers 6, 7.
  • Code fails compilation at line numbers 4, 5, 6, 7, 9. (Correct)
  • Runtime exception

Answer :Code fails compilation at line numbers 4, 5, 6, 7, 9.

Given the following code, which option, if used to replace //INSERT CODE HERE, will enable a reference variable of type Roamable to refer to an object of the Phone class? (Choose one)


Options are :

  • C. Roamable var = (Roamable)new Phone(); (Correct)
  • D. Because the interface Roamable and the class Phone are unrelated, a reference variable of the type Roamable can't refer to an object of the class Phone.
  • B. Roamable var = (Roamable)Phone();
  • A. Roamable var = new Phone();

Answer :C. Roamable var = (Roamable)new Phone();

Paul defined his Laptop and Workshop classes to upgrade his laptop's memory. Do you think he succeeded? What is the output of this code? (Choose one)


Options are :

  • 2 GB (Correct)
  • Runtime exception
  • 1 GB
  • Compilation error

Answer :2 GB

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

Given the following code, which option, if used to replace /* INSERT CODE HERE */, will enable the class Jungle to determine whether the reference variable animal refers to an object of the class Lion and print 1? (Choose one)


Options are :

  • A. if (animal instanceof Lion) (Correct)
  • B. if (animal instanceOf Lion)
  • C. if (animal == Lion)
  • D. if (animal = Lion)

Answer :A. if (animal instanceof Lion)

What is the output of the following code? (Select 1 option.)


Options are :

  • D. 45Heart 45Heart
  • B. 45Liver 0Heart
  • A. 45Heart 0Liver (Correct)
  • C. 45Liver 45Heart
  • E. Class fails to compile.

Answer :A. 45Heart 0Liver

What is the output of the following code? (Select 1 option.)


Options are :

  • 0
  • null0.0AB
  • null0default
  • null0AB
  • Compilation error (Correct)

Answer :Compilation error

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

Given the following code, which option, if used to replace //INSERT CODE HERE, will make the code print numbers that are completely divisible by 14? (Choose one)


Options are :

  • D. end;
  • B. exit;
  • C. break;
  • A. continue; (Correct)

Answer :A. continue;

Given the following code,

what's its output if it's executed using the following command? (Choose one)

java MainMethod 1+2 2*3 4-3 5+1


Options are :

  • MainMethod:6
  • 1+2:4-3
  • 31
  • 1+2:2*3 (Correct)
  • java:1+2
  • 4
  • MainMethod:2*3

Answer :1+2:2*3

What is the output of the following code? (Choose one)


Options are :

  • Corn CornA
  • Corn BornA
  • Corn Corn (Correct)
  • Corn Born

Answer :Corn Corn

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

What is the output of the following code? (Select 1 option.)


Options are :

  • null0false025
  • 0.0ffalse025
  • Compilation error
  • Runtime exception
  • null0.0false025 (Correct)

Answer :null0.0false025

What is the output of the following code? (Choose one)


Options are :

  • Compilation error (Correct)
  • Smartphone
  • landline
  • No output

Answer :Compilation error

Given the following,

which options, when inserted at //INSERT CONSTRUCTOR HERE, will define valid overloaded constructors for the class Home? (Choose all that apply)


Options are :

  • A. Home() {} (Correct)
  • F. float Home(int rooms, String name) {}
  • G. static Home() {}
  • D. final Home() {}
  • C. protected Home(int rooms) {} (Correct)
  • E. private Home(long name) {} (Correct)
  • B. Float Home() {}

Answer :A. Home() {} C. protected Home(int rooms) {} E. private Home(long name) {}

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

A bank's swift code is generally of 11 characters and used in international money transfers. 
An example of swift code: ICICINBBRT4
ICIC: First 4 letters for bank code
IN: Next 2 letters for Country code
BB: Next 2 letters for Location code
RT4: Next 3 letters for Branch code

Which of the following code correctly extracts country code from the swift code referred by String reference variable swiftCode?


Options are :

  • swiftCode.substring(5, 6);
  • swiftCode.substring(4, 6); (Correct)
  • swiftCode.substring(5, 7);
  • swiftCode.substring(4, 5);

Answer :swiftCode.substring(4, 6);

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

Consider below code:

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


Options are :

  • 100:0
  • 16:0
  • 0:0 (Correct)
  • 16:16
  • 100:100

Answer :0:0

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


Options are :

  • -99
  • -101
  • 99
  • -100 (Correct)
  • Compilation error

Answer :-100

____________ uses access modifiers to protect variables and hide them within a class.

Which of the following options accurately fill in the blanks above?


Options are :

  • Inheritance
  • Polymorphism
  • Encapsulation (Correct)
  • Abstraction

Answer :Encapsulation

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

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


Options are :

  • Core
  • true
  • CoRe (Correct)
  • false

Answer :CoRe

Given code:


And below statements:

1. short arr [] = new short[2];

2. byte [] arr = new byte[10];

3. short [] arr; arr = new short[3];

4. short [2] arr;

5. short [3] arr;

6. int [] arr = new int[]{100, 100};

7. int [] arr = new int[]{0, 0, 0, 0};

8. short [] arr = {};

9. short [] arr = new short[2]{5, 10};


How many above statements can be used to replace /*INSERT*/, such that on execution, code will print [5, 10] on to the console?


Options are :

  • Only three options (Correct)
  • None of the given options
  • Only four options
  • Only one option
  • More than four options
  • Only two options

Answer :Only three options

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


Options are :

  • [1919-02-25, 1980-12-31]
  • [2018-07-11, 1919-02-25, 2020-04-08, 1980-12-31]
  • [2018-07-11, 2020-04-08] (Correct)
  • Runtime exception

Answer :[2018-07-11, 2020-04-08]

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

Consider below code: 

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


Options are :

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

Answer :No, HELLO is not printed on the console

Consider below code:

And the commands:
javac Guest.java

java Guest Clare Waight Keller


What is the result?


Options are :

  • Welcome Keller! (Correct)
  • ArrayIndexOutOfBoundsException is thrown at runtime
  • Welcome Waight!
  • Compilation error as main method is not public in Message class
  • Some other error as main method can't be invoked manually
  • Welcome Clare!

Answer :Welcome Keller!

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


Options are :

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

Answer :false

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

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


Options are :

  • Tesla Model S
  • null
  • Compilation Error (Correct)
  • Tesla Model X

Answer :Compilation Error

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


Options are :

  • You passed…
  • You failed…
  • Produces no output
  • Compilation error (Correct)

Answer :Compilation error

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions