Become Oracle Certified with updated 1Z0-808 exam questions and correct answers
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.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);
}
}
Given the code fragment:

Consider below code of Test.java file:
1. package com.sampleproject.oca;
2.
3. interface Perishable1 {
4. default int maxDays() {
5. return 1;
6. }
7. }
8.
9. interface Perishable2 extends Perishable1 {
10. default int maxDays() {
11. return 2;
12. }
13. }
14.
15. class Milk implements Perishable2, Perishable1 {}
16.
17. public class Test {
18. public static void main(String[] args) {
19. Perishable1 obj = new Milk();
20. System.out.println(obj.maxDays());
21. }
22. }
Which of the following statements is correct?
Consider below codes of 3 java files:
1. //M.java
2. package com.sampleproject.oca;
3.
4. public class M {
5. public void printName() {
6. System.out.println("M");
7. }
8. }
1. //N.java
2. package com.sampleproject.oca;
3.
4. public class N extends M {
5. public void printName() {
6. System.out.println("N");
7. }
8. }
1. //Test.java
2. package com.sampleproject.oca.test;
3.
4. import com.sampleproject.oca.*;
5.
6. public class Test {
7. public static void main(String[] args) {
8. M obj1 = new M();
9. N obj2 = (N)obj1;
10. obj2.printName();
11. }
12. }
What will be the result of compiling and executing Test class?
Consider below code of Test.java file:
1. package com.sampleproject.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. int i = 1;
6. int j = 5;
7. int k = 0;
8. A: while(true) {
9. i++;
10. B: while(true) {
11. j--;
12. C: while(true) {
13. k += i + j;
14. if(i == j)
15. break A;
16. else if (i > j)
17. continue A;
18. else
19. continue B;
20. }
21. }
22. }
23. System.out.println(k);
24. }
25. }
What will be the result of compiling and executing Test class?
© 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.