• OCA: Java 8 Programmer I Study Guide • OCP: Java 8 Programmer II Study Guide • OCA / OCP Java 8 Practice Tests • OCP Java 11 Programmer I Study Guide • OCP Java 11 Programmer II Study Guide • OCP Java 11 Developer Complete Study Guide • OCP Java 11 Practice Tests Win a book at the end!
List<Integer> list = List.of(1, 2, 3); var list = List.of(1, 2, 3); • Syntactical sugar/less boilerplate • Type Fixed • Value Mutable (unlike val from Kotlin) 8
= 1; var b = a; double c = b; System.out.println(c); A. a does not compile B. b does not compile C. c does not compile 21 D. 1.0 E. None of the above D
i + 1) .takeWhile(i -> i < 5) .forEach(System.out::println); Assumes ordered stream. Takes all elements until one doesn’t match. So prints the numbers 1-4
-> new SimpleEntry<Integer,Integer>( e.getValue(), e.getKey()+e.getValue())) .map(Entry::getValue) .takeWhile(n -> n < 30) .forEach(System.out::println); How print all Fibonacci #s less than 30?
i + 1) .dropWhile(i -> i < 5) .forEach(System.out::println); Assumes ordered stream. Takes all elements until one doesn’t match. So prints the numbers 5-9
list = Arrays.asList(1, 2, 3); list.remove(2); System.out.println(list); A. [1, 2, 3] B. [1, 3] C. [1, 2] 42 D. Code does not compile E. Throws exception
list = Arrays.asList(1, 2, 3); list.remove(2); System.out.println(list); A. [1, 2, 3] B. [1, 3] C. [1, 2] 43 D. Code does not compile E. Throws exception E
count = Stream .iterate(1; i-> i< 10; i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 44 D. The code does not compile E. None of the above
count = Stream .iterate(1; i-> i< 10; i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 45 D. The code does not compile E. None of the above D
i-> i< 10, i-> i++) .takeWhile(i -> i < 5) .forEach(System.out::println); A. The numbers 1-4 B. The numbers 5-9 C. An infinite stream 46 D. The code does not compile E. None of the above
i-> i< 10, i-> i++) .takeWhile(i -> i < 5) .forEach(System.out::println); A. The numbers 1-4 B. The numbers 5-9 C. An infinite stream 47 D. The code does not compile E. None of the above C
count = Stream .iterate(1, i-> i< 10, i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 48 D. The code does not compile E. None of the above
count = Stream .iterate(1, i-> i< 10, i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 49 D. The code does not compile E. None of the above B
A single class can be exported. B. A single package can be exported C. They require a module-def file D. They require a module-info file E. None of the above 65
A single class can be exported. B. A single package can be exported C. They require a module-def file D. They require a module-info file E. None of the above 66 B, D