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

Which of the following are valid declarations?


Options are :

  • double d =123._456;
  • double d =123.4_5_6; (Correct)
  • double d =123.456; (Correct)
  • double d =123.456_;

Answer :double d =123.4_5_6; double d =123.456;

Consider the following declarations:

Which of the above declarations are equal syntactically ?


Options are :

  • 2,3
  • 1,2,3 (Correct)
  • 1,2,4
  • 1,2

Answer :1,2,3

Java applications can run on various devices and computers without performing any modifications. This feature is called


Options are :

  • Multi-threaded
  • Robustness
  • Platform independent Nature (Correct)
  • Secure

Answer :Platform independent Nature

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

Consider the code:

What is the result ?


Options are :

  • ab
  • The Compilation Fails.
  • 195 (Correct)
  • An exception is thrown at runtime.

Answer :195

Consider the code:

What is the result ?


Options are :

  • false false
  • true true (Correct)
  • The Compilation Fails.
  • An exception is thrown at runtime.

Answer :true true

Consider the code:

What is the result?


Options are :

  • 20
  • 10 (Correct)
  • Compilation Fails.
  • An exception is thrown at runtime.

Answer :10

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

Which of the following are valid two-dimensional array declarations ?


Options are :

  • int[][] a = new int[][] {{10,20},{30,40}};
  • int[][] a = new int[2][2];
  • int[][] a = {{10,20},{30,40}};
  • All of these. (Correct)

Answer :All of these.

Consider the code:

What is the result ?


Options are :

  • null null
  • An exception thrown at runtime.
  • [Ljava.lang.String;@7852e922 null (Correct)
  • The compilation fails.

Answer :[Ljava.lang.String;@7852e922 null

Consider the code:

What is the result ?


Options are :

  • The Compilation Fails.
  • An exception is thrown at runtime.
  • 7
  • 0 (Correct)

Answer :0

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

Consider the statements :

S1: If we perform any changes to primitive values which are passed to a method, those changes will be reflected to the caller method.

S2: If we perform any changes to instance variables of Objects which are passed to a method, those changes will be reflected to the caller method.

Which of the above statements are valid ?


Options are :

  • Only S1.
  • Only S2. (Correct)
  • Both S1 and S2.
  • None of S1 and S2.

Answer :Only S2.

Consider the code:

What is the result ?


Options are :

  • The Compilation Fails.
  • An exception is thrown at runtime.
  • false true (Correct)
  • false false

Answer :false true

Consider the array:

int[] x = {10,20,30,40};

Which of the following represents the number of elements present inside array?


Options are :

  • x.size
  • x.length (Correct)
  • x.size()
  • x.length()

Answer :x.length

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

Which of the following are valid array declarations?


Options are :

  • int[] x = new char[10];
  • None of these.
  • double[] d = new float[10];
  • Object[] o = new String[10]; (Correct)

Answer :Object[] o = new String[10];

Consider the following code:

and the command invocation

java Test Core Java Advanced Java


What is the result?


Options are :

  • CoreJava
  • CoreJavaAdvancedJava
  • TestCoreJavaAdvancedJava
  • An exception is thrown at runtime. (Correct)

Answer :An exception is thrown at runtime.

Consider the code:

Which of the following are TRUE ?


Options are :

  • It prints 65720 to the console.
  • Compilation Fails at Line-2.
  • Compilation Fails at Line-1.
  • An exception is thrown at runtime.
  • Compilation Fails at Line-3. (Correct)
  • Compilation Fails at Line-4. (Correct)

Answer :Compilation Fails at Line-3. Compilation Fails at Line-4.

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

Which of the following are True?


Options are :

  • Java code compiled on Linux can run on windows. (Correct)
  • Java is Procedural Programming language.
  • All of the above.
  • Java is Object Oriented Programming language. (Correct)

Answer :Java code compiled on Linux can run on windows. Java is Object Oriented Programming language.

Consider the code:

What is the result?


Options are :

  • The Compilation Fails. (Correct)
  • 1020
  • An exception is thrown at runtime.
  • ab

Answer :The Compilation Fails.

Consider the code:

What is the result?


Options are :

  • 21.0
  • 24.0
  • The Compilation Fails. (Correct)
  • An exception is thrown at runtime.

Answer :The Compilation Fails.

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

Consider the following code:

What is the result?


Options are :

  • An exception is thrown at runtime.
  • The Compilation Fails.
  • 1020 (Correct)
  • 102030

Answer :1020

Consider the code:

What is the result ?


Options are :

  • null...true...0
  • The Compilation Fails
  • ...false...0
  • null...false...0 (Correct)

Answer :null...false...0

In which scenarios would a do-while loop be preferable to a while loop? (Choose all that apply)


Options are :

  • B. Guess an answer until the answer is correct. (Correct)
  • A. Admit one ticket-holder at a time into a movie theater until there are no more ticket-holders to admit.
  • D. Add candles to a birthday cake until there are the right number of candles. (Correct)
  • E. Let the mice play a little while the cat is away.
  • C. Add a little salt to the food until the food tastes right. Assume the food has too little salt to start with. (Correct)

Answer :B. Guess an answer until the answer is correct. D. Add candles to a birthday cake until there are the right number of candles. C. Add a little salt to the food until the food tastes right. Assume the food has too little salt to start with.

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

Which statement is true about the following program? (Choose one)


Options are :

  • The program will compile. When run, it will print: Sorry. OK. (Correct)
  • The program will not compile.
  • The program will compile. When run, it will print: Sorry.
  • The program will compile. When run, it will print: OK.

Answer :The program will compile. When run, it will print: Sorry. OK.

Given the following interface declaration, which declaration is valid? (Choose one)


Options are :

  • interface D implements I { void increment(); }
  • abstract class C implements I { int getValue() { return 0; } abstract void increment(); }
  • class A extends I { int value; void setValue(int val) { value = val; } int getValue() { return value; } }
  • interface B extends I { void increment(); } (Correct)

Answer :interface B extends I { void increment(); }

Which digits, and in what order, will be printed when the following program is compiled and run? (Choose one)


Options are :

  • The program will print 5.
  • The program will print 1 and 4, in that order. (Correct)
  • The program will print 1, 2, 4, and 5, in that order.
  • The program will print 1, 4, and 5, in that order.
  • The program will print 1, 2, and 4, in that order.
  • The program will print 3 and 5, in that order.

Answer :The program will print 1 and 4, in that order.

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

Which expression will evaluate to true? (Choose one)


Options are :

  • "HELLO THERE".equals("hello there")
  • "Hello There".compareTo("hello there") == 0
  • "hello: there!".equals("hello there")
  • ("hello".concat("there")).equals("hello there")
  • "Hello there".toLowerCase().equals("hello there") (Correct)

Answer :"Hello there".toLowerCase().equals("hello there")

What will the following program print when run? (Choose one)


Options are :

  • 5 (Correct)
  • 9
  • 11
  • None of the above.
  • 2
  • 7
  • 4

Answer :5

Which statement about the charAt() method of the String class is true? (Choose one)


Options are :

  • The index of the first character is 1.
  • The expression "abcdef".charAt(3) evaluates to the character 'd'. (Correct)
  • The expression ("abcdef").charAt(3) is illegal.
  • The charAt() method takes a char value as an argument.
  • The charAt() method returns a Character object.

Answer :The expression "abcdef".charAt(3) evaluates to the character 'd'.

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

What will the following program print when compiled and run? (Choose all that apply)


Options are :

  • (1) will print [Ada, Anna, Otto]. (Correct)
  • (2) will print [Ada, Anna, Otto, Otto, Anna, Ada]. (Correct)
  • (1) will print [Ada, Alyla, Anna].
  • (2) will print [Ada, Otto, Alyla, Alyla, Otto, Ada].

Answer :(1) will print [Ada, Anna, Otto]. (2) will print [Ada, Anna, Otto, Otto, Anna, Ada].

Which operators will always evaluate all the operands? (Choose all that apply)


Options are :

  • | |
  • + (Correct)
  • &&
  • % (Correct)
  • ? :

Answer :+ %

What will the following program print when compiled and run? (Choose all that apply)


Options are :

  • (2) will print 4. (Correct)
  • (1) will print: [Taco, Taco, Taco, Taco, Taco, Taco, Taco, Taco]
  • (1) will print: [Taco, [Taco], Taco, [Taco], Taco, [Taco], Taco, [Taco]]
  • (2) will print 8.
  • (1) will print: [Taco, [Taco], [Taco, [Taco]], [Taco, [Taco], [Taco, [Taco]]]] (Correct)

Answer :(2) will print 4. (1) will print: [Taco, [Taco], [Taco, [Taco]], [Taco, [Taco], [Taco, [Taco]]]]

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

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions