Oracle Certified Associate
Practice Set 02

Java SE 8 Programmer I exam (1Z0 | 808) Certification

Duration 120 minutes,
Format: Multiple Choice
Number of Questions: 56
Passing Score: 65%

Questions from 01 to 14

Question 01.

Type correct answers.
What should replace line 07 to get the output as shown below, use the code fragments and type your answer.
Given:

01. public class Demo {
02.    public static void main (String args []){
03.       String output = append("Mr.");
04.       System.out.print(output);
05.    }
06.    static String append(String str) {
07.        // insert the code here.
08.        return str;
09.    }
10. }


Output:
Mr. Robert

Code Fragment:
str
" Robert"
=
+=
;


str += " Robert";

Question 02.

Select the most appropriate answer.
Which of the following is lambda expression syntax?


Option a: (argument-list) == {body}
Option b: [{argument-list}] ->> {body}
Option c: {body} --> (argument-list)
Option d: (argument-list) ~> {body}
Option e: (argument-list) -> {body}


Option e: (argument-list) -> {body}

Question 03.

Select the most appropriate answer.
Given:

public class Cheetah{
   public void jump(int i) {
      System.out.print("int ");
   }
   public void jump(long l) {
      System.out.print("long ");
   }
   public static void main(String[] args) {
      Plane p = new Plane();
      p.jump(123);
      p.jump(123L);
   }
}


Option a: int long
Option b: long int
Option c: Upon execution generates compiler error.
Option d: Upon execution generates runtime error.


Option a: int long

Question 04.

Select the most appropriate answer.
What is the output?
Given:

int x = 0;
int y = 9;
x++;
x++;
x++;
y--;
System.out.print(y/x);


Option a: 1
Option b: 3
Option c: 2
Option d: 4


Option c: 2

Question 05.

Select the most appropriate answer.
For the snippet below what is the output?
Given:

int i = 100;
if (i > 200 && i < 700) {
   if (i == 200) System.out.print("In range. Its 2 x 100.");
   else if (i == 300) System.out.print("In range. Its 3 x 100.");
   else if (i == 400) System.out.print("In range. Its 4 x 100.");
   else if (i == 500) System.out.print("In range. Its 5 x 100.");
   else if (i == 600) System.out.print("In range. Its 6 x 100.");
   else System.out.print("In range. But not a nultiple of 100. It's " + i); 
}  else if (i < 200 ) {System.out.print("Below Range");
}   else { System.out.print("Above Range"); }


Option a: In range. Its 2 x 100.
Option b: In range. Its 3 x 100.
Option c: In range. Its 4 x 100.
Option d: In range. Its 5 x 100.
Option e: In range. Its 6 x 100.
Option f: In range. Its 7 x 100.
Option g: In range. But not a multiple of 100. It's 100
Option h: Below Range
Option i: Above Range


Option h: Below Range

Question 06.

Select the most appropriate answer.
What is the result?
Given:

int i = 300;
switch (i/100 + (i%100 == 0 ? 0: 5)) {
case 1:
   System.out.println("1 x 100. "+i + " is multiple of 100.");
case 2:
   System.out.println("2 x 100. "+i + " is multiple of 100.");
case 3:
   System.out.println("3 x 100. "+i + " is multiple of 100.");
case 4:
   System.out.println("4 x 100. "+i + " is multiple of 100.");
default:
   System.out.println(i + " is not multiple of 100.");\n }


Option a:
2 x 100. 300 is multiple of 100.
3 x 100. 300 is multiple of 100.
4 x 100. 300 is multiple of 100.
300 is not multiple of 100.
Option b:
3 x 100. 300 is multiple of 100.
4 x 100. 300 is multiple of 100.
300 is not multiple of 100.
Option c:
3 x 100. 300 is multiple of 100.
300 is not multiple of 100.
Option d:
3 x 100. 300 is multiple of 100.


Option b:
3 x 100. 300 is multiple of 100.
4 x 100. 300 is multiple of 100.
300 is not multiple of 100.

Question 07.

Type correct answers.
Type your answer using the code fragments. 
Given:

1: public class InitializationOrder {
2:    private String name = "Torchie";
3:    { System.out.println(name); }
4:    private static int COUNT = 0;
5:     static { System.out.println(COUNT); }
6:     { COUNT++; System.out.println(COUNT); }
7:     public InitializationOrder() {
8:        System.out.println("constructor");
9:     }
10:   public static void main(String[] args) {
11:        System.out.println("read to construct");
12:        // Insert code here.
13:    }
14: }


Gives the Output:
0
read to construct
Torchie
1
constructor

Code Fragments:
new
InitializationOrder
Initialization
Order
(
)


new InitializationOrder();

Question 08.

Select the most appropriate answer.
What is the result of the following program?

public class Colors{
   private String color;
   public Colors() {
      color = "White";
   }
   public static void main(String[] args) {
      Colors c = new Colors();
      System.out.println("Color:" + c.color);
   }
}



Option a: Color:
Option b: Color:null
Option c: Color:White
Option d: Compiler error.
Option e: Runtime error. 


Option c: Color:White

Question 09.

Select the most appropriate answer.
which lines follow JavaBeans naming conventions:?

12: public String str() { return str; }
13: public boolean getDancing() { return dancing; }
14: private String str; 
15: public void updateString(String s) { name = s; }
16: private boolean dancing;
17: public boolean isDancing() { return dancing; }
18: public void setstring(String s) { name = s; } 


Option a: Follow: 14, 17, 18; Don’t Follow: 12, 13, 15, 16;
Option b: Follow: 14, 16, 17; Don’t Follow: 12, 13, 15, 18;
Option c: Follow: 12, 14, 17; Don’t Follow: 13, 15, 16, 18;
Option d: Follow: 12, 14, 15; Don’t Follow: 13, 16, 17, 18;


Option b: Follow: 14, 16, 17; Don’t Follow: 12, 13, 15, 18; 

Question 10.

Select all correct answers.
Which of the following are true?


Option a: % operator is used to calculate the remainder.
Option b: * operator is used to calculate the remainder.
Option c: ! operator is used to calculate the quotient.
Option d: / operator is used to calculate the quotient. 


Option a: % operator is used to calculate the remainder.
Option d: / operator is used to calculate the quotient.

Question 11.

Select the most appropriate answer.
What is the output?
Given:

public class Pattern {
   public static void main(String args[]) {
      int i, j, row = 6;
      for (i = 0; i < row; i++) {
         for (j = row - i; j > 1; j--) {
            System.out.print(" ");
        }
        for (j = 0; j <= i; j++) {
           System.out.print("* ");
        }
       System.out.println();
    }
  }
}


Option a:
* * * * * *
* * * * *
* * * *
* * *
* *
*
Option b:
*
* *
* * *
* * * *
* * * * *
* * * * * *
Option c:
*
* *
* * *
* * * *
* * * * *
Option d:
* * * * * *


Option b:
*
* *
* * *
* * * *
* * * * *
* * * * * * 

Question 12.

Select all correct answers.
Which of the following are true?


Option a: Symbol ‘ && ’ is used to perform logical AND operation.
Option b: Symbol ‘ | | ’ is used to perform logical OR operation.
Option c: Symbol ‘ != ’ is used to perform logical NOT operation.
Option d: NOT operator accepts a multiple value as input, compares and returns the inverse of the same.
Option e: OR operation is true only if both expression1 and expression2 are true


Option a: Symbol ‘ && ’ is used to perform logical AND operation.
Option b: Symbol ‘ | | ’ is used to perform logical OR operation.
Option e: OR operation is true only if both expression1 and expression2 are true

Question 13.

Type correct answers.
Given:
Which of the code fragments shown above should be inserted to get the output as ‘false’. Type your answer 

public class OperatorTest {
   public static void main(String[] args) {
      int a = 7, b = 11;
      System.out.println(//Insert code here.);
   }
}


Output:
false

Code Fragments:
a >= b
a != b
a < b
a <= b


a >= b

Question 14.

Select the most appropriate answer.
What is the output for the given code below?
Given:

public class Pattern2 {
   public static void main(String[] args) {
      int i, j, k = 1; 
      for (i = 1; i <= 5; i++) {
         for (j = 1; j < i + 1; j++) {
            System.out.print(k++ + " ");
         }
        System.out.println();
     }
  }
}


Option a:
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
Option b: Generates runtime error.
Option c:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Option d: Compilation error. 


Option c:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

 OCA Practice Tests (1Z0-808) app contributes in achieving Oracle Certified Associate (OCA) certification.

A total of 10 premium tests are provided.

The purpose of these practice tests is to assist Oracle Certified Associate (OCA) Aspirants to manage time better in the actual exam by asking them to answer questions similar to the ones that appear in exams. The test series helps you assess your preparation and identify your weakness well before the exam, thus assisting you prepare better.

Tests also include features like:
• 60 minutes, 15 minutes and 5 minutes remaining voice alerts.
• After completion, your performance is assessed and a report is generated.
• App also provides correct answers for the test after completion.

Mobirise Website Builder
https://play.google.com/store/apps/details?id=in.co.vtree.ocamobiletab

Contact Details :---             
WhatsApp Number: +91 97422 63639              Telegram Number:  +91 97422 63639    
Mobile Number: +91 97422 63639              email id: contact@drdhajnana.com
Privacy Policy       Terms of Service
vtree.co.in

Designed with ‌

Offline Website Creator