Note this was presented before the exam objectives came out. While it might help you learn some Java 11 material, it will *not* prepare you for the exam.
our first books. 2. Some of the material in this presentation may appear in our upcoming certification books. 3. Oracle can announce anything (I don’t work for Oracle.) 4
in interfaces 2 effectively final try with resources, var 3 Collections and Strings 4 Single file execution, deprecation and JShell 5 Streams 6 Jigsaw, Multi release jar files 7 Study tips, harder questions/review
Lecture • Practice questions as a group/discussion • Hands on exercises • 10 minute break This means if a colleague needs to call you, the last 15-20 minutes of each hour is best. 7
Open JDK New version Every 3 years Every 6 months Cost Paid Free Upgrade Options • Next version • Security patch • Open JDK • Interim security patch • Next version
the resources are ResultSets? try (resource1; resource2) {} A. Resource 1 is closed before resource 2 B. Resource 2 is closed before resource 1 C. Neither is closed since declared before try D. The code does not compile 50
the resources are ResultSets? try (resource1, resource2) {} A. Resource 1 is closed before resource 2 B. Resource 2 is closed before resource 1 C. Neither is closed since declared before try D. The code does not compile 52
var a = 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 53 D. 1.0 E. None of the above
var a = 1; var b = a; String c = b; System.out.println(c); A. a does not compile B. b does not compile C. c does not compile 55 D. 1 E. None of the above
output? Map<Integer, Integer> map = Map.of(1, 2, 3, 4); System.out.println(map.get(2)); A. 1 B. 2 C. null 70 D. Code does not compile E. Throws exception
output? List<Integer> list = List.of(1, 2, 3); list.remove(2); System.out.println(list); A. [1, 2, 3] B. [1, 3] C. [1, 2] 76 D. Code does not compile E. Throws exception
output? List list = Arrays.asList(1, 2, 3); list.remove(2); System.out.println(list); A. [1, 2, 3] B. [1, 3] C. [1, 2] 78 D. Code does not compile E. Throws exception
the blank to print 1? char whitespace = '\u001D'; String str = whitespace + "x"; System.out.println( str.________().length()); A. stripLeading() B. stripTrailing() 79 C. strip() D. None of the above
output? List list = Arrays.asList(1, 2, 3); list.set(1, 0); System.out.println(list); A. [1, 0, 3] B. [1, 2, 3] C. null 80 D. Code does not compile E. Throws exception
the blank to print 1? char whitespace = '\t'; String str = whitespace + "x"; System.out.println( str.________().length()); A. stripLeading() B. stripTrailing() 81 C. trim() D. None of the above
output? List<Integer> list = List.of(1, 2, 3); list.set(1, 0); System.out.println(list); A. [1, 0, 3] B. [1, 2, 3] C. null 82 D. Code does not compile E. Throws exception
some people to believe that nothing would ever be removed. On the other hand, other people believed that everything that was deprecated might eventually be removed, which was never the intent either.” From JEP 277
the intent to remove API from Java at some point? since String Version of Java when API first became deprecated (not populated for all pre- Java 9 APIs) Only had for new APIs before
way to run a Java program? A. java HelloWorld B. java HelloWorld.java C. javac HelloWorld.java java HelloWorld D. javac HelloWorld.java java HelloWorld.class 99
can run this program? package x; public class Module4 { public static void main(String[] args) {} } A. java Test B. java x.Test.java C. java x/Test.java 101 D. java x/Test E. None of the above
can run this program? public class Module4 { public static void main(String[] args) { java.util.List l = null; } } A. java Test B. java Test.java C. Neither 102
can run this program? public class Module4 { public static void main(String[] args) { x.MyClass c = null; } } A. java Test B. java Test.java C. Neither 103
deprecation values? A. forRemoval = false, since = null B. forRemoval = true, since = null C. forRemoval = false, since = 1.9 D. forRemoval = true, since = 1.9 105
+ 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?
+ 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
output? long count = Stream .iterate(1; i-> i< 10; i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 115 D. The code does not compile E. None of the above
output? Stream.iterate(1, 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 116 D. The code does not compile E. None of the above
output? long count = Stream .iterate(1, i-> i< 10, i-> i+2).count(); System.out.println(count); A. 0 B. 5 C. 10 117 D. The code does not compile E. None of the above
output? long count = Stream.ofNullable(null).count(); System.out.println(count); A. 0 B. 1 C. null 118 D. The code does not compile E. None of the above
output? Stream.iterate(1, i-> i< 10, i-> ++i) .dropWhile(i -> i < 5) .forEach(System.out::println); A. The numbers 1-4 B. The numbers 5-9 C. An infinite stream 119 D. The code does not compile E. None of the above
of the property to enable multi- release jars? A. MultiRelease=on B. MultiRelease=true C. Multi-Release=on D. Multi-Release=true E. None of the above 137
of the property to enable multi- release jars? A. MultiRelease=on B. MultiRelease=true C. Multi-Release=on 142 D. Multi-Release=true E. None of the above
multi module jar? 2. What flag did you use to specify version? 3. How many modules are built in? Which look most useful? 4. Did anyone succeed in packaging a module? 145
8 • Study Guide (ex: Mine!) • Mock Exams (ex: Enthuware) • Study at least 15 minutes a day (advice courtesy of Bert Bates) • Create a plan (even if don’t follow) 146
Line x1 doesn’t compile B. Line x2 doesn’t compile C. Line x3 doesn’t compile D. MAX is accessible to implementing classes E. max2() is accessible to implementing classes 151
modules? A. 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 153
var with try with resources? A. For an effectively final variable used in a try with resources declaration B. In the catch declaration C. In an instance variable referenced by the body of the try with resources D. In a try with resources declaration 155
multi-release jars? A. An older version of Java will ignore folders for newer versions. B. Newer versions are designated with a version folder in the root directory C. They can be unzipped in WinZip D. You can create a “8” folder for Java 8 projects. 157
A. If strip() returns true, trim() will always return true. B. If stripLeading() returns true, trim() will always return true. C. If trim() returns true, strip() will always return true. D. If trim() returns true, stripLeading() will always return true. 159