My Experience taking the new Java SE 11 Programmer II 1Z0-816 Exam

Update (11/05/2020): Read The 1Z0-819 Exam page to learn how you can easily our Java 11 Study Guides to prepare for Oracle’s 1Z0-819 Exam, as well as the 1Z0-817 Upgrade Exam.

Back in March, I took the new Java SE 11 Programmer I 1Z0-815 Exam only 2 days after it was released. Going into the exam blind, I wasn’t too worried because the previous OCA 8 1Z0-808 exam had been such a breeze. Boy was I surprised! While I passed with a decent margin, I was shocked the level of difficulty of the Programmer I 1Z0-815 exam. It was nothing like the 1Z0-808 exam it inherits from, especially in terms of question difficulty!

This past month, Jeanne and I finished writing our new Java OCP 11 Programmer I Study Guide (now available for preorder), which meant it was time to turn our attention to our upcoming Java OCP 11 Programmer II Study Guide. Rather than go in blind, and especially given all of the new material, I decided to spend some time studying *before* taking the 1Z0-816 exam. Well, it paid off because I passed today with a quite a wide margin. Below are some of my impressions of the exam.

Level of Difficulty

This might sound crazy, and I’m sure I’m biased, but overall I found the 1Z0-816 OCP11 exam less difficult than the OCP 8 1Z0-809 exam it inherits from. Don’t get me wrong, it was a difficult exam, but I felt like there were so many topics and they were so broad, the exam rarely went into especially deep detail on some of them. For example, many of the questions regarding SQL injection had pretty clear answers. In most of the questions, I was able to eliminate completely “ridiculous” answers right away, getting the answer choices down to 2 (or 3 if it was pick 2, or 4 if it was pick 3, etc). In fact, some questions I didn’t even need to read the text to whittle down the answer choices. For example, if an answer choice is an invalid lambda expression, it clearly cannot be a valid answer. With that in mind, most questions boiled down eliminating bad answers, then reading the question text to know which of the two remaining choices was correct.

Better Focused

One of the best changes they made in the new 1Z0-815/1Z0-816 exam series was to move most of the core Java syntactical questions to the first exam. While they made the 1Z0-815 exam harder, it made the 1Z0-816 exam a lot clearer. For example, if a question appears to be about NIO.2 on the 1Z0-816 exam, then it’s about NIO.2! On the older 1Z0-809 exam, I always felt like they mixed common Java topics with advanced ones. For example, a question that appears to be about NIO.2 on the 1Z0-809 exam might actually be about constructor overloading or overriding methods. In other words, the 1Z0-816 exam is better because the questions are derived from the objectives more cleanly, and there aren’t as many trick questions. You still have to know a lot to pass, but at least they aren’t mixing topics as much as they did in previous exams.

Streams, Streams, Streams

While the exam seemed reasonable to me, I’m also very proficient in streams. It is an understatement to say they are all over the exam. If you don’t use them regularly, you’ll need a lot of practice before taking the exam. Remember, they can show up in almost any topic like NIO.2, Concurrency, Collections, etc.

Modules

Modules are on the exam but I found the questions a lot more straight-forward than the module questions I saw on the 1Z0-815 exam. I had a lot of trouble with the module questions on the 1Z0-815 exam, in part because a lot of them didn’t make sense or didn’t appear to have a correct answer. Given how early I took the exam, Jeanne suspects I might have been exposed to beta/experimental/broken questions. That said, I thought the module questions on the 1Z0-816 exam were a lot more fair than they were on the 1Z0-815 exam. You need to know a lot about modules, of course, but the topics the questions were testing were a lot clearer.

Still a Very Broad Exam

While questions within a topic were relatively straight-forward, the amount of topics you had to know for the 1Z0-816 exam dwarfs the 1Z0-809 exam. Annotations, Security, Local Type Inference, Private/Static Interface Methods, and Modules are completely new. You should read the Secure Coding Guideline and Annotations Trail prior to taking the exam. Unfortunately, there’s not one single source of material for modules so you have to study from what you can piece together on the web… that is until our new 1Z0-816 study guide is released!

So You Want to Take the Exam?

Great! If you’re not in a hurry, I would wait for our new study guides to come out. The first book is already on its way to print and the second book will be available early next year. You can use our OCP 8 Study Guide to take exam, but you will have to supplement it with a lot of reading from a dozen different sources. And as I said earlier, if you’re not using streams regularly, you will definitely need a lot of practice. Regardless of which path you take, we wish you the best in studying!

DevNexus 2018 – Modules in Action

Title: Modules in Action
Speakers: Mark Reinhold

For more blog posts, see the DevNexus 2018 live blogging table of contents


Demo used Java 10 RC.

Using JShell to look at modules

  • “foo”.getClass().getModule() – module java.base
  • “foo”.getClass().getModule().getClass() – class java.lang.Module
  • new java.sql.Timestamp(0).getModule() – module java.sql

Modules

  • java –list-modules – ex: java.sql@10
  • There are 75 modules in Open JDK 10

JavaDoc

  • The Java 9 JavaDoc shows modules on the home page instead of all the packages.
  • Clicking a module shows you the packages in the module.
  • Java 9 JavaDoc has search box

Random facts

  • tree – unix commands that list what is in directory and children (not installed by default)
  • Showed that can use * in classpath to get all files in lib directory. (since Java 6)

Creating a bare bones module

  • Create module-info.java file in root of src folder
  • Simplest module file is one line: module moduleName { }
  • If run javap against the class file, you can see “requires java.base;” was added. This is like a constructor calling super(). It is mandatory so you don’t need to type it.
  • jar –file x.jar –describe-module – shows name of file, requires and the package contained
  • java –module-path lib -m moduleName/className – run the program
  • java -classpath jar className – can still run a modular jar on the classpath
  • jar –create –file x.jar –main-class class -C classes – create a jar that can run without specifying the class to run
  • java –modulepath lib -m moduleName – run the program without specifying it by name

Refactoring the module to split into two

  • module module1 { requires packageName; }
  • module module2 { exports packageName; }

Problems

  • If remove module2 and try to run, get java.lang.module.FindException on startup since can’t find module. Error inlcudes “Error occurred during initialization of boot layer”
  • If forgot to type “requires”, and compile get “package x is not visible”
  • If two modules require each other and compile, get “cyclic dependence involving package x”
  • If forget to type “exports” and compile, get “IllegalAccessError exception” along with long message about exporting

jlink

  • Optional Java linker
  • New directory jmods in JAVA_HOME.
  • Each module in the JDK has a file in jmods
  • JDK got a lot bigger with Java 9 because shipping two copies of each module – the main one and the jmods directory
  • jlink –module-path $JAVA_HOME.jmods –output jre –add-modules java.base – creates a JRE that is an order of magnitude smaller than the full one (44M vs 329B)
  • Can include your custom app into the image in addition to JDK
  • jlink –module-path $JAVA_HOME.jmods:lib –output jrePlusApp –add-modules java.base myCustomModule
  • jlink has a –compress flag to make file smaller
  • Not platform independent. Can cross link to create file for other operating system

Reflection

  • Want to make it so private really means private and final really means final. Vs reflection today.
  • Illegal reflective access – first time, get warning. The warning tells you how to enable more warnings. There probably are, but don’t want to blast you with them. Eventually, warning will turn into a hard error.
  • Not planning to disallow illegal reflective access until after Java 11.
  • Supplementing “exports”, is “open. It allows extra reflection

Inside a jmod

  • jmods are like a zip file with extra structure.
  • classes directory with all of the classes
  • conf directory for files in runtime image
  • include directory for jni header files
  • legal directory with licenses if any
  • bin directory for launchers
  • lib directory for native code

My take

I like the live demo approach along with the emphasis on both concepts and common problems. I also like that Mark left a lot of time for Q&A.