Special Offer! November Sale at DumpsCity! Get 20% Off on All Certification Exam Questions. Use Code: DC20OFF
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
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
52. 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.
1. package com.sampleproject.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. /*INSERT*/ x = 7, y = 200;
6. System.out.println(String.valueOf(x + y).length());
7. }
8. }
Which of the following options, if used to replace /*INSERT*/, will compile successfully and on execution will print 3 on to the console?
Select 3 options.
1. package com.sampleproject.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. try { //outer
6. try { //inner
7. System.out.println(1/0);
8. } catch(ArithmeticException e) {
9. System.out.println("INNER");
10. } finally {
11. System.out.println("FINALLY 1");
12. }
13. } catch(ArithmeticException e) {
14. System.out.println("OUTER");
15. } finally {
16. System.out.println("FINALLY 2");
17. }
18. }
19. }
What will be the result of compiling and executing Test class?
© Copyrights Dumpscity 2024. All Rights Reserved
We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the Dumpscity.