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

Which of the following are true? (Choose all that apply)


Options are :

  • E. If the code is fixed to compile, half of the cells in the 2D array have a value of 0. (Correct)
  • B. Two lines need to be changed for this code to compile.
  • A. One line needs to be changed for this code to compile. (Correct)
  • F. If the code is fixed to compile, all of the cells in the 2D array have a value of 0.
  • C. Three lines need to be changed for this code to compile.
  • D. If the code is fixed to compile, none of the cells in the 2D array have a value of 0.

Answer :E. If the code is fixed to compile, half of the cells in the 2D array have a value of 0. A. One line needs to be changed for this code to compile.

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

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


Options are :

  • E. The code throws an exception on line s2. (Correct)
  • A. Fall
  • C. The code does not compile.
  • B. Spring
  • D. The code throws an exception on line s1.

Answer :E. The code throws an exception on line s2.

Which of the following is a valid code comment in Java? (Choose all that apply)


Options are :

  • C. // Is this a bug? (Correct)
  • E. /*** TODO: Call grandma ***/ (Correct)
  • F. # Updated code by Patti
  • D. / Begin method - performStart() /
  • B. /****** Find the kitty cat */ (Correct)
  • A. /** Insert */ in next method **/

Answer :C. // Is this a bug? E. /*** TODO: Call grandma ***/ B. /****** Find the kitty cat */

Given the following three class declarations, which sets of access modifiers can be inserted, in order, into the blank lines below that would allow all of the classes to compile? (Choose all that apply)


Options are :

  • D. protected and protected (Correct)
  • E. private and public
  • C. package-private (blank) and protected (Correct)
  • A. protected and package-private (blank)
  • F. package-private (blank) and package-private (blank)
  • B. public and public (Correct)

Answer :D. protected and protected C. package-private (blank) and protected B. public and public

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

Which of the following are true statements? (Choose all that apply)


Options are :

  • B. The java command compiles a .class file into a .java file.
  • D. The javac command compiles a source text file into a bytecode file. (Correct)
  • E. The java command compiles a .java file into a .class file.
  • F. The javac command compiles a .class file into a .java file.
  • C. The javac command compiles a .java file into a .class file. (Correct)
  • A. The javac command compiles a source text file into a set of machine instructions.

Answer :D. The javac command compiles a source text file into a bytecode file. C. The javac command compiles a .java file into a .class file.

What is the output of the following when run as java EchoFirst seed flower plant? (Choose one)


Options are :

  • F. The output is not guaranteed. (Correct)
  • C. 2
  • A. 0
  • B. 1
  • D. The code does not compile.
  • E. The code compiles but throws an exception at runtime.

Answer :F. The output is not guaranteed.

Fill in the blanks: The operators +=,_____ ,_____ ,_____ ,_____ , and ++ are listed in increasing or the same level of operator precedence. (Choose all that apply))


Options are :

  • C. =, +, /, * (Correct)
  • E. *, /, %, -- (Correct)
  • B. %, *, /, +
  • A. , +, =, --
  • D. ^, *, -, ==

Answer :C. =, +, /, * E. *, /, %, --

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

Fill in the blanks: The _______ keyword is used in method declarations, the _______  keyword is used to guarantee a statement will execute even if an exception is thrown, and the _______  keyword is used to throw an exception to the surrounding process.


Options are :

  • B. throws, catch, throw
  • A. throw, finally, throws
  • D. finally, catch, throw
  • C. catch, finally, throw
  • E. throws, finally, throw (Correct)

Answer :E. throws, finally, throw

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


Options are :

  • D. The code does not compile.
  • A. b (Correct)
  • E. The code compiles but throws an exception at runtime.
  • B. black
  • C. lack

Answer :A. b

What statements are true about compiling a Java class file? (Choose all that apply)


Options are :

  • E. Java requires every file to declare at least one import statement.
  • C. The compiler assumes every class implicitly imports the java.util.* package.
  • A. If the file does not contain a package statement, then the compiler considers the class part of the java.lang package.
  • B. The compiler assumes every class implicitly imports the java.lang.* package. (Correct)
  • D. Java requires every file to declare a package statement.
  • F. If the class declaration does not extend another class, then it implicitly extends the java.lang.Object class. (Correct)

Answer :B. The compiler assumes every class implicitly imports the java.lang.* package. F. If the class declaration does not extend another class, then it implicitly extends the java.lang.Object class.

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

Given a class that uses the following import statements, which class would be automatically accessible without using its full package name? (Choose all that apply)


Options are :

  • F. forest.ape.bonobo
  • A. forest.Bird (Correct)
  • D. java.lang.Object (Correct)
  • C. jungle.tree.Huicungo (Correct)
  • B. savana.sand.Wave
  • E. forest.Sloth

Answer :A. forest.Bird D. java.lang.Object C. jungle.tree.Huicungo

How many lines of the following application contain compilation errors?


Options are :

  • A. None. The code compiles and runs without issue.
  • C. Two
  • D. Three (Correct)
  • B. One
  • E. Four

Answer :D. Three

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


Options are :

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

Answer :C. 1 2

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

How many lines of the following application do not compile? (Choose one)


Options are :

  • C. One (Correct)
  • E. Three
  • A. None. The code compiles and prints swim!.
  • B. None. The code compiles and prints a stack trace.
  • D. Two

Answer :C. One

How many lines does this code output? (Choose one)


Options are :

  • D. None. It doesn't compile.
  • A. One (Correct)
  • B. Two
  • E. None. It throws an exception at runtime.
  • C. Three

Answer :A. One

What is the result of running the following program? (Choose one)


Options are :

  • E. The code compiles but throws a different exception at runtime.
  • F. The output is not guaranteed.
  • A. 6
  • D. The code compiles but throws a NullPointerException at runtime. (Correct)
  • C. The code does not compile.
  • B. X

Answer :D. The code compiles but throws a NullPointerException at runtime.

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

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


Options are :

  • A. It only prints Hello.
  • D. It does not compile because of line g1.
  • C. It only prints See you again.
  • F. None of the above (Correct)
  • B. It only prints Goodbye.
  • E. It does not compile because of line g2.

Answer :F. None of the above

Fill in the blanks: Using the ________ and ________  modifiers together allows a variable to be accessed from any class, without requiring an instance variable.


Options are :

  • E. default, public
  • B. class, static
  • C. protected, instance
  • A. final, package-private
  • D. public, static (Correct)

Answer :D. public, static

Which of the following are true right before the main() method ends? (Choose all that apply)


Options are :

  • B. One object is eligible for garbage collection. (Correct)
  • A. No objects are eligible for garbage collection.
  • C. Two objects are eligible for garbage collection.
  • E. One object is guaranteed to be garbage collected.
  • F. Two objects are guaranteed to be garbage collected.
  • D. No objects are guaranteed to be garbage collected. (Correct)

Answer :B. One object is eligible for garbage collection. D. No objects are guaranteed to be garbage collected.

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

Which of the following variable types is permitted in a switch statement? (Choose all that apply)


Options are :

  • E. String (Correct)
  • A. Character (Correct)
  • D. long
  • B. Byte (Correct)
  • C. Double
  • F. Object

Answer :E. String A. Character B. Byte

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


Options are :

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

Answer :C. 3 2

What is the output if this class is run with java Indexing cars carts? (Choose one)


Options are :

  • E. The code compiles but throws an exception at runtime. (Correct)
  • B. cars carts
  • C. ccars arts
  • D. The code does not compile.
  • A. cars

Answer :E. The code compiles but throws an exception at runtime.

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

Which modifiers can be independently applied to an interface method? (Choose all that apply)


Options are :

  • C. static (Correct)
  • B. protected
  • A. default (Correct)
  • F. abstract (Correct)
  • D. private
  • E. final

Answer :C. static A. default F. abstract

What is printed by the following code snippet?


Options are :

  • E. It does not compile.
  • D. 99
  • B. 13 (Correct)
  • C. 18
  • A. 49

Answer :B. 13

Which statements best describe the result of this code? (Choose all that apply)


Options are :

  • E. The code throws an exception at runtime. (Correct)
  • C. The println causes three lines of output.
  • A. The println causes one line of output.
  • D. The code terminates successfully.
  • B. The println causes two lines of output. (Correct)

Answer :E. The code throws an exception at runtime. B. The println causes two lines of output.

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

Which of the following use generics and compile without warnings? (Choose all that apply)


Options are :

  • E. List e = new ArrayList(); (Correct)
  • F. List<> f = new ArrayList();
  • A. List a = new ArrayList();
  • D. List<> d = new ArrayList<>();
  • B. List<> b = new ArrayList();
  • C. List c = new ArrayList<>(); (Correct)

Answer :E. List e = new ArrayList(); C. List c = new ArrayList<>();

Which of the following statements about inheritance are true? (Choose all that apply)


Options are :

  • C. Inheritance allows objects to inherit commonly used attributes and methods. (Correct)
  • E. Inheritance tends to make applications more complicated.
  • B. Inheritance allows a method to be overridden in a subclass, possibly changing the expected behavior of other methods in a superclass. (Correct)
  • A. Inheritance is better than using static methods for accessing data in other classes.
  • D. It is possible to create a Java class that does not inherit from any other.

Answer :C. Inheritance allows objects to inherit commonly used attributes and methods. B. Inheritance allows a method to be overridden in a subclass, possibly changing the expected behavior of other methods in a superclass.

Which of the following statements about java.lang.Error are most accurate? (Choose all that apply)


Options are :

  • E. An Error should be thrown if a user enters invalid input.
  • A. An Error should be thrown if a file system resource becomes temporarily unavailable.
  • B. An application should never catch an Error. (Correct)
  • D. It is possible to catch and handle an Error thrown in an application. (Correct)
  • C. Error is a subclass of Exception, making it a checked exception.

Answer :B. An application should never catch an Error. D. It is possible to catch and handle an Error thrown in an application.

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

How many lines does this program print? (Choose one)


Options are :

  • D. This is an infinite loop.
  • A. None (Correct)
  • C. Two
  • B. One
  • E. The code does not compile.

Answer :A. None

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


Options are :

  • B. The declaration of _number does not compile.
  • C. The declaration of profit$$$ does not compile.
  • E. The code compiles and runs successfully.
  • D. The println statement does not compile. (Correct)
  • F. The code compiles and throws an exception at runtime.
  • A. The declaration of name does not compile.

Answer :D. The println statement does not compile.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions