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

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


Options are :

  • B. 11789 (Correct)
  • C. 11717
  • A. 56789
  • D. The code does not compile.

Answer :B. 11789

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

What is the result of compiling and executing the following class? (Choose one)


Options are :

  • B. It compiles but throws an exception at runtime.
  • D. It compiles and outputs 15.
  • A. It does not compile. (Correct)
  • c. It compiles and outputs 5.

Answer :A. It does not compile.

What symbol is used for a varargs method parameter? (Choose one)


Options are :

  • A. ..
  • C. --
  • D. ---
  • B. ... (Correct)

Answer :B. ...

Which type of loop is best known for its boolean condition that controls entry to the loop?


Options are :

  • D. while (Correct)
  • A. do-while loop
  • C. for-each
  • B. for (traditional)

Answer :D. while

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

Given the following method declaration, which line can be inserted to make the code compile? (Choose one)


Options are :

  • B. return new Byte((byte)6); (Correct)
  • D. return new Short(4).longValue();
  • A. return new Integer(3);
  • C. return 5L;

Answer :B. return new Byte((byte)6);

Which of the following does not compile? (Choose one)


Options are :

  • B. int num = 9_9_9;
  • C. int num = _9_99; (Correct)
  • A. int num = 999;
  • D. None of the above; they all compile.

Answer :C. int num = _9_99;

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


Options are :

  • C. The code does not compile. (Correct)
  • B. Hop!
  • A. Jump!
  • D. The code compiles but throws an exception at runtime.

Answer :C. The code does not compile.

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

Which starts counting from one rather than zero? (Choose one)


Options are :

  • A. Array indexes
  • B. The index used by charAt in a String
  • C. The months in a LocalDateTime (Correct)
  • D. The months in a LocalTime

Answer :C. The months in a LocalDateTime

What does the following code output? (Choose one)


Options are :

  • B. aaa
  • A. aa (Correct)
  • D. This is an infinite loop.
  • C. The loops complete with no output.

Answer :A. aa

Which of the following is not a facet of traditional object-oriented programming languages? (Choose one)


Options are :

  • B. An object can take many forms via casting.
  • D. An object can perform actions, via methods.
  • C. An object can hold data, referred to as attributes.
  • A. Objects are grouped as procedures, separate from the data they act on. (Correct)

Answer :A. Objects are grouped as procedures, separate from the data they act on.

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

Which of the following method signatures is a valid declaration of an entry point in a Java application? (Choose one)


Options are :

  • B. public static void main()
  • C. private static void start(String[] mydata)
  • D. public static final void main(String[] mydata) (Correct)
  • A. public void main(String[] args)

Answer :D. public static final void main(String[] mydata)

What statement about the ^ operator is correct? (Choose one)


Options are :

  • A. If one of the operands of ^ is true, then the result is always true.
  • C. If both operands of ^ are true, the result is true.
  • B. There is a conditional form of the operator, denoted as ^^.
  • D. The ^ operator can only be applied to boolean values. (Correct)

Answer :D. The ^ operator can only be applied to boolean values.

What is the proper filename extension for a Java bytecode compiled file? (Choose one)


Options are :

  • A. .java
  • B. .bytecode
  • C. .class (Correct)
  • D. .dll

Answer :C. .class

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

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


Options are :

  • D. The code does not compile. (Correct)
  • C. The application does not produce any output at runtime.
  • B. Finished!, followed by a stack trace
  • A. Finished!

Answer :D. The code does not compile.

Which of the following statements about calling this() in a constructor is not true? (Choose one)


Options are :

  • D. If the no-argument this() is called, then the class must explicitly implement the no-argument constructor.
  • C. If arguments are provided to this(), then there must be a constructor in the class able to take those arguments.
  • B. If super() and this() are both used in the same constructor, super() must appear on the line immediately after this(). (Correct)
  • A. If this() is used, it must be the first line of the constructor.

Answer :B. If super() and this() are both used in the same constructor, super() must appear on the line immediately after this().

Which is not a true statement about the Period class? (Choose one)


Options are :

  • D. You can create a Period representing 5 years.
  • B. A Period is typically used for adding or subtracting time from dates.
  • A. A Period is immutable.
  • C. You can create a Period representing 2 minutes. (Correct)

Answer :C. You can create a Period representing 2 minutes.

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

What is the result of the following when run with

java peregrine.TimeLoop September 3 1940?


Options are :

  • B. 1940
  • D. None of the above (Correct)
  • A. September
  • C. The code does not compile.

Answer :D. None of the above

Which of the following method signatures does not contain a compiler error? (Choose one)


Options are :

  • C. public void sing(String... keys, String... pitches)
  • A. public void sing(String key, String... harmonies) (Correct)
  • B. public void sing(int note, String... sound, int music)
  • D. public void sing(String... notes, String melodies)

Answer :A. public void sing(String key, String... harmonies)

Which of the following variable types is not permitted in a switch statement? (Choose one)


Options are :

  • C. int
  • A. String
  • B. double (Correct)
  • D. char

Answer :B. double

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

Given the following class definition, what is the maximum number of import statements that can be discarded and still have the code compile? For this question, assume that the Blackhole class is defined only in the stars package.


Options are :

  • B. One
  • C. Two
  • A. Zero
  • D. Three (Correct)

Answer :D. Three

How many 1s are outputted when the following application is compiled and run?


Options are :

  • D. The code does not compile. (Correct)
  • C. Two
  • A. None
  • B. One

Answer :D. The code does not compile.

Which of the following classes will handle all types in a catch block? (Choose one)


Options are :

  • C. Throwable (Correct)
  • B. Error
  • D. RuntimeException
  • A. Exception

Answer :C. Throwable

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

Which of the following create an empty two-dimensional array with dimensions 22? (Choose one)


Options are :

  • B. int[][] blue = new int[2], [2];
  • A. int[][] blue = new int[2, 2];
  • D. int[][] blue = new int[2 x 2];
  • C. int[][] blue = new int[2][2]; (Correct)

Answer :C. int[][] blue = new int[2][2];

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


Options are :

  • A. 2 1 (Correct)
  • C. The code does not compile.
  • D. The code compiles but throws an exception at runtime.
  • B. 2 2

Answer :A. 2 1

What is the first line in the following code to not compile? (Choose one)


Options are :

  • C. k3
  • A. k1
  • C. k4
  • B. k2 (Correct)

Answer :B. k2

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

What is the output of the following application?


Options are :

  • A. Awake!, followed by a stack trace
  • D. The code does not compile because of line x3.
  • C. The code does not compile because of line x2.
  • B. The code does not compile because of line x1. (Correct)

Answer :B. The code does not compile because of line x1.

How many compiler errors does the following code contain? (Choose one)


Options are :

  • B. One
  • D. Three (Correct)
  • A. None
  • C. Two

Answer :D. Three

Which statement immediately exits a switch statement, skipping all remaining case or default branches? (Choose one)


Options are :

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

Answer :B. break

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

Fill in the blank to make the code compile:


Options are :

  • C. cat.setName
  • A. cat.name (Correct)
  • B. cat-name
  • D. cat[name]

Answer :A. cat.name

What does the following code output? (Choose one)


Options are :

  • C. The loop completes with no output.
  • A. ab
  • D. This is an infinite loop. (Correct)
  • B. abab

Answer :D. This is an infinite loop.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions