Free Oracle 1Z0-808 Exam Questions

Become Oracle Certified with updated 1Z0-808 exam questions and correct answers

Page:    1 / 122      
Total 608 Questions | Updated On: Jan 09, 2025
Add To Cart
Question 1

Consider below code:

1. //Test.java

2. package com.udayan.oca;

3.  

4. import java.util.ArrayList;

5. import java.util.Iterator;

6. import java.util.List;

7. import java.util.function.Predicate;

8.  

9. class Employee {

10.      private String name;

11.      private int age;

12.      private double salary;

13.  

14.      public Employee(String name, int age, double salary) {

15.          this.name = name;

16.          this.age = age;

17.          this.salary = salary;

18.      }

19.  

20.      public String getName() {

21.          return name;

22.      }

23.  

24.     public int getAge() {

25.          return age;

26.      }

27.  

28.     public double getSalary() {

29.          return salary;

30.      }

31.  

32.     public String toString() {

33.          return name;

34.      }

35. }

36.  

37. public class Test {

38.      public static void main(String [] args) {

39.          List list = new ArrayList<>();

40.          list.add(new Employee("James", 25, 15000));

41.          list.add(new Employee("Lucy", 23, 12000));

42.          list.add(new Employee("Bill", 27, 10000));

43.          list.add(new Employee("Jack", 19, 5000));

44.          list.add(new Employee("Liya", 20, 8000));

45.  

46.          process(list, /*INSERT*/);

47.  

48.          System.out.println(list);

49.      }

50.  

51.      private static void process(List list, Predicate predicate) {

52.          Iterator iterator = list.iterator();

53.          while(iterator.hasNext()) {

54.              if(predicate.test(iterator.next()))

55.              iterator.remove();

56.          }

57.       }

58. }

Which of the following lambda expressions, if used to replace /*INSERT*/, prints [Jack, Liya] on to the console?

Select 2 options.


Answer: B,C
Question 2

Given code:

package com.udayan.oca;

 

public class Test {

    public static void main(String[] args) {

        /*INSERT*/

        arr[1] = 5;

        arr[2] = 10;

        System.out.println("[" + arr[1] + ", " + arr[2] + "]"); //Line n1

    }

}

And below statements:

1. short arr [] = new short[2];

2. byte [] arr = new byte[10];

3. short [] arr; arr = new short[3];

4. short [2] arr;

5. short [3] arr;

6. int [] arr = new int[]{100, 100};

7. int [] arr = new int[]{0, 0, 0, 0};

8. short [] arr = {};

9. short [] arr = new short[2]{5, 10};

How many above statements can be used to replace /*INSERT*/, such that on execution, code will print [5, 10] on to the console?


Answer: C
Question 3

Consider below code:

1. package com.udayan.oca;

2.  

3. public class Test {

4.     public static void main(String[] args) {

5.         StringBuilder sb = new StringBuilder();

6.         try {

7.             for(;;) {

8.                 sb.append("OCA");

9.             }

10.         } catch(Exception e) {

11.             System.out.println("Exception!!!");

12.         }

13.         System.out.println("Main ends!!!");

14.     }

15. }

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


Answer: D
Question 4

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

package com.udayan.oca;

 

import java.util.ArrayList;

import java.util.List;

 

public class Test {

     public static void main(String[] args) {

         List list = new ArrayList<>();

         list.add(100);

         list.add(7);

         list.add(50);

         list.add(17);

         list.add(10);

         list.add(5);

 

         list.removeIf(a -> a % 10 == 0);

 

         System.out.println(list);

     }

}


Answer: A
Question 5

Given the code fragment:

HPE6-A70
Which option represents the state of the num array after successful completion of the outer loop?


Answer: A
Page:    1 / 122      
Total 608 Questions | Updated On: Jan 09, 2025
Add To Cart

© Copyrights DumpsCertify 2025. All Rights Reserved

We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the DumpsCertify.