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

Which of the following can fill in the blanks to make this code compile?
__________ d = _________ new (10_000_.00);


Options are :

  • double, Double
  • Double, Double
  • double, double
  • None of these can make the code compiled (Correct)

Answer :None of these can make the code compiled

What is the output of this program?


Options are :

  • true
  • false (Correct)
  • Code has compilation error
  • Code will compile, but throws an exception at runtime

Answer :false

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

Which one is a correct statement about the following code?


Options are :

  • variable "string" cannot be used in the line 1
  • string++ is invalid in the line 3
  • while loop condition occurs an error (Correct)
  • The code will compile without any error

Answer :while loop condition occurs an error

In the below code, which Java code should be in the indicated line so that the output will be  "99NN 99NN"?


Options are :

  • myString.append("NN"); s = s.concat("NN"); (Correct)
  • myString.append("NN"); s = s.append("NN");
  • myString.append("NN"); s.myString;
  • myString.concat("NN"); s = s.concat("NN");

Answer :myString.append("NN"); s = s.concat("NN");

In the following code, which type of variable the card  is?


Options are :

  • card is of type Card (Correct)
  • card is of type Birthday
  • card is of type both Card and Birthday
  • none

Answer :card is of type Card

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

What is the output of the following application?


Options are :

  • 145
  • 1045
  • 24, followed by a stack trace
  • 245 (Correct)
  • The code does not compile because of line p1.
  • The code does not compile because of line p2.

Answer :245

Fill in the blanks to indicate whether a primitive or wrapper class can be assigned without autoboxing feature.


Options are :

  • Integer, Integer
  • int, String
  • int, Integer (Correct)
  • Integer, int

Answer :int, Integer

Which code in following would produce output 3  3? 


Options are :

  • System.out.println(a[0] + " " + b[0]);
  • System.out.println(a[1] + " " + b[2]);
  • System.out.println(a[1] + " " + b[1]); (Correct)
  • System.out.println(a[2] + " " + b[2]);

Answer :System.out.println(a[1] + " " + b[1]);

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

What is the output of the following code?


Options are :

  • Canada
  • Compilation error
  • null
  • Cyprus (Correct)

Answer :Cyprus

What is the output of this program?


Options are :

  • true (Correct)
  • false
  • Compilation error
  • null

Answer :true

How will you call a default method of an interface in a class?


Options are :

  • Using this keyword along with the interface
  • Using name of the interface
  • Using super keyword along with interface name (Correct)
  • default method can not be called in interface

Answer :Using super keyword along with interface name

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

Which one is the correct code for creating an object of the Product class? 



Options are :

  • Product hammer = new Product();
  • hammer.Product();
  • Product hammer = new Product(124, Hammaer35, 35.00);
  • Product hammer = new Product("A23B4", "Claw Hammer 2 pond", 24.95); (Correct)

Answer : Product hammer = new Product("A23B4", "Claw Hammer 2 pond", 24.95);

Which line of the code produce an compilation error? 


Options are :

  • line 2
  • line 6 (Correct)
  • line 9
  • line 10

Answer :line 6

Fill in the blanks: A class ____________ an abstract class, while a class ___________ an interface.


Options are :

  • implements, implements
  • extends, extends
  • extends, implements (Correct)
  • implements, extends

Answer :extends, implements

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

Which code will print the numbers between 7 and 14 inclusive, by printing output in every line? 


Options are :

  • int n = 7; do { System.out.print( n ); System.out.print("\n"); }while( x < 15 );
  • int n = 7; do { System.out.print( n ); n++; System.out.print("\n"); } while( x < 14 );
  • int n = 7; do { System.out.print(n ); n++; System.out.print("\n"); } while( x < 15 ); (Correct)
  • int n = 8; do { System.out.print( n ); n++; System.out.print("\n"); }while( x < 14 );

Answer : int n = 7; do { System.out.print(n ); n++; System.out.print("\n"); } while( x < 15 );

What is the result of the following code?


Options are :

  • The will not compile
  • Hi
  • The code will compile but throws an exception at runtime
  • The loop will continue forever (Correct)

Answer :The loop will continue forever

What is the output of the following?


Options are :

  • 0 1 2
  • Canada
  • Canada USA Mexico (Correct)
  • Compilation error

Answer :Canada USA Mexico

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

What is the result of this code?


Options are :

  • 8
  • x + q
  • 0
  • Code has an error with runtime exception (Correct)

Answer :Code has an error with runtime exception

Given the application below and the choices available, which lines must all be removed to

allow the code to compile? (Choose three.)


Options are :

  • Line 8
  • Line 9
  • Line 10 (Correct)
  • Line 11 (Correct)
  • Line 12 (Correct)
  • Line 13

Answer :Line 10 Line 11 Line 12

What is the output of the following?


Options are :

  • can,cup,
  • cup,can,
  • The code does not compile.
  • This is an infinite loop.
  • The code compiles but throws an exception at runtime. (Correct)

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

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

What will be the result of compiling and executing Circus


Options are :

  • Cat Animal
  • Cat Deer
  • Animal Deer (Correct)
  • Animal Animal

Answer :Animal Deer

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

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


Options are :

  • Line 4 causes compilation failure
  • An exception is thrown at runtime by Line 6
  • Line 2 causes compilation failure
  • Line 8 causes compilation failure (Correct)
  • null

Answer :Line 8 causes compilation failure

Which of the following can be used as a constructor for the class given below?


Options are :

  • public void Planet(int x){}
  • None of the other options
  • public Planet(String str) {} (Correct)
  • public void Planet(){}

Answer :public Planet(String str) {}

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


Options are :

  • Executes successfully but no output
  • DONE
  • None of the above
  • Compilation error (Correct)

Answer :Compilation error

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

Which of the method of String class is used to remove leading and trailing white spaces?


Options are :

  • rtrim()
  • trim() (Correct)
  • ltrim()
  • trimBoth()

Answer :trim()

Predict Output, if the above code is run with given command?

java Test


Options are :

  • NullPointerException is thrown at runtime (Correct)
  • No Output
  • Compilation error
  • ArrayIndexOutOfBoundsException is thrown at runtime

Answer :NullPointerException is thrown at runtime

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


Options are :

  • 1 2 3
  • Compilation error (Correct)
  • 65 66
  • A B

Answer :Compilation error

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

Which of the following is the correct package declaration to declare Test class in com.exam.oca package?


Options are :

  • package com.exam.oca; (Correct)
  • package com.exam.oca.*;
  • Package com.exam.oca;
  • package com.exam.oca.Test;

Answer :package com.exam.oca;

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


Options are :

  • Compilation error
  • null null (Correct)
  • null Good Evening!
  • Good Evening! null

Answer :null null

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


Options are :

  • false:false
  • true:true
  • NullPointerException is thrown at runtime
  • null:null (Correct)

Answer :null:null

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

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions