var var = "var" (2/2)

The Good and The Bad Parts Of the Java OCP exam

This is a follow-up of a previous post in which I talked about my challenges in obtaining the Oracle Certified Professional (OCP) exam for Java 11.

Here, I'd like to give some insights into why I would not recommend the OCP exam as a way to learn Java.

Incentive

Before you start investing your time in learning something, it makes sense to ask yourself what you want to get out of it. Of course, this highly depends on your experience, role and interest.

In my case, I wanted to be more fluent with Java, spending less time on stackoverflow and more time in the IDE writing idiomatic Java. I planned to use these skills in my everyday work, transforming business concepts into backend code.

What I liked Photo by Daniel K Cheung on Unsplash

What I liked

Since everybody likes a good feedback sandwich 🥪, here is what I liked about the OCP exam:

Boost Intuition

To pass the exam, learning by heart is not enough. Instead, you must tackle the questions with intuition for the language. In everyday coding life, this intuition is helpful to quickly understand compiler errors, runtime issues, or simply to know where standard functionality is located in the core API.

To obtain this intuition, I see two paths:

  1. Work multiple years with Java and, over time, learn from your mistakes and also memorize some core API. I call this the natural experience path.

  2. Prepare for a Java certificate like OCP. Work your way through hundreds of mock exam questions, fail, assess, repeat, fail again and eventually succeed. This is what I did.

Preparing for the exam via option 2 boosts your Java language intuition in a short time since it lets you deal with common mistakes in a compressed way.

Favorite Topics

You do a pretty extensive tour around Java SE by studying for the exam. Here is a very personal selection of topics I am thankful to have understood deeper:

  • generic- versus primitive streams (e.g. Stream<Integer> versus IntStream)
  • generics, type erasure and the impact on overriding and overloading
  • stream aggregation via reduce or groupBy, including the weird repetition of intermediate stream operations in the collectors API via filtering or mapping
  • class and object initialization. This is the interplay of static variables, static initializers, instance variables, instance initializers and the constructor
  • the fact that a finally block is always executed
  • Handling multi-threading with Executors
  • Java IO streams. They have been in Java since the very beginning. Nevertheless, they are still relevant. The AWS SDK is an excellent example of that.

What I did not like Photo by Hello I'm Nik on Unsplash

What I did not like

Unfortunately, we now arrive at the "this was not so good part" and, to be honest, the reason for this blog post.

I found the exam-style an inefficient and often unpleasant way to extend my Java knowledge. As there is no single reason for that, here is the list of some of my pain points:

No Pain, no gain

Over time, the enjoyment of learning fainted, particularly when taking mock exam after mock exam. The spirit now was more "no pain, no gain", and I had flashbacks to unpleasant learning experiences back in my university days. These emotions were in total contrast to the curiosity and excitement I usually feel when learning something new.

Time pressure

The exam presents you with 50 multiple-choice questions, which you have to answer in 90 minutes. These 90 minutes can be really short without dedicated training using mock exams.

I found it weird to train to answer technical questions under time pressure. It often felt like being drilled for a sports competition and not like learning for an intellectual challenge.

vi style code examples

The code examples are given as simple text without syntax highlighting. I once had a colleague who coded Java in a monochrome terminal in vi - he would have loved it.

However, syntax colouring is not a fancy tool but a standard. It helps our brain to comprehend the code. Hence, I don't see the point in training to be good at reading vi style Java classes.

Too detailed language specification knowledge

Some questions expect you to have a very detailed, memorized knowledge of the Java SE language spec. For example, did you know that all of these code snippets correctly declare and initialize an int array ?:

  • int [][] a = new int[1][]
  • int a [][] = new int[1][]
  • int [] a [] = new int[1][]
  • var a = new int[1][]

The exam expects you to know all of these variants (also for generic types) and identify invalid ones. I consider the first and the last example necessary syntax. The rest are obscure syntax variations that the compiler will assist me with when spotted in code.

Unnecessary emphasis on API learning

Some questions require you to have method names and signatures memorized. So is it Executors.newSingleThreadExecutor(...) or Executors.getSingleThreadExecutor(...) - it's your choice, time is ticking ⌛.

Sticking with this example, what I actually would have liked to memorize is that there is a utility class Executors which contains factory methods to obtain

  • a single-threaded ExecutorService
  • an ExecutorService based on a fixed amount of threads
  • an ExecutorService for scheduled background tasks

For further details, variants and more specific ExecutorServices, go and see the JavaDoc. Nothing more.

Other questions require knowing the return type of a method by heart. Here is an example:

// What is the result of this code snippet?

IntStream myInts = IntStream.of(1,2,3);
int count = myInts.count(); 
System.out.println(count);

The above example does not compile since the count() terminal operation returns long and not int. 🤦‍♂️

Here is the reason why I believe these types of questions are unnecessary:

Intellisense discovers type

People earning their money with Java spend their days inside the IDE, which assists you, e.g. by hinting you a return type. There is no point in learning this by heart.

Over-proportional love for arrays

In terms of data structures, there was a surprising amount of questions around arrays. I understand that if you want to call yourself a professional Java developer, you should be aware of them and know how to use them.

Java arrays mostly appear as parameters of a vargs method in my everyday work. However, the array is almost always converted to a List for better handling. So as an application developer, I don't see the benefit of training to mentally parse and execute low-level Java code, which iterates a multi-dimensional array using nested for loops.

Find the missing checked exception

Some questions contain code that you believe executes correctly - except that a method required you to either declare or handle a checked exception 👿. I don't understand the benefit of tricking a student like that. Your IDE instantly starts to scream at you in real life, so there is no way to let such a coding issue slip through.

Syntax edge case questions

I assume it depends on your history with Java, what you consider a "syntax edge case". However, I regularly got frustrated by finding out the hard way (failing a mock question) that, e.g. var var = "var"; or String _$ = ""; is valid Java and compiles.

Don't get me wrong. It is nice to surprise your fellow workmates with some piece of unexpected syntax - this is where geek-fun begins. However, it should not be required knowledge in professional certification.

My Perfect Learning Path Photo by Christian Lue on Unsplash

My perfect learning path

As already mentioned, I would not choose the OCP exam again. Instead, I would pick a more applied and hands-on learning experience.

Ideally, the whole learning effort circles around a simple project which gradually grows as new concepts are introduced. Working with code does not ignore but embrace standard tooling like an IDE.

Whenever convenient, the course side-tracks to explore some aspects deeper. For example, if there is a need to work with files, the course detours and covers the java.nio.files package. The Path and the Files classes are introduced, and the three most used methods are detailed.

However, no energy is wasted on learning method signatures by heart. There are only two things to take away (and memorize): the Path and Files classes are your friend when dealing with files.

I also would like to see a deeper focus on object-oriented modelling. So you've learned all the mechanics of abstract classes and interfaces. How to build something useful with these tools?

Since an applied format is hard to examine via multiple-choice questions, students instead comment on each other's work to gather feedback. I had good experiences with this approach during Massive Open Online Courses (MOOC).

These are just my thoughts based on the exam preparation experience. I did not do market research, but please feel free to comment to benefit other learners if you know a suitable course.

Value of the certification

Before I check out, a quick remark about the "Oracle Certified Professional Java Programmer" certification in general:

I often read that the certificate holders are provided with better job opportunities. Maybe this is the case in your part of the world. In the little tech bubble in my area of Germany, I hardly know a person with this certificate.

Moreover, none of the recruiters I have talked to was aware of the certificate's existence. The market for experienced Java developers is hot, so I don't feel that the certificate gives me a bonus.

Conclusion

Thank you for making it down here. The OCP certification helped me a lot to improve my Java skills. However, I think the learning format is not ideal. If you plan to invest in your Java foo, I advise you to consider more hands-on alternatives.

Credits

...go to

  • Franziska, for allowing me to go through this madness ❤️
  • Shawn @ Let's get certified, for sound advice, simple explanations and for sharing that even a "pro" can find this certification challenging 🤝
  • Ferdi, for reviewing this little blog post series 🤓
  • Uwe, for the late evening question answering 🦉
  • 2x Jan, for listening and encouraging me 👍