ocp java 8 programmer II beta

Scott and I both took the OCP (Oracle Certified Professional) Java 8 Programmer II beta exam this week.

(edit: I’m now OCP certified with an 88%)

Logistics

We both had 106 questions. It was a three hour exam. I needed two hours for my first pass of the questions. I marked about 25 questions for review and used the remaining time for those. The nice thing about a beta is that you get lots of questions. Sometimes one question gives a clue for another question. For example (not on the exam), maybe you aren’t sure if a method is called set() or put(). Then you get to a question that uses put() and doesn’t have “does not compile” as a choice. Perfect. Now you know something.

As always, you can review questions you’ve marked or all questions in order. The only way to go to a specific question is if you’ve marked it for review. Otherwise you could potentially be clicking next scores of times. I tend to click a lot for review so this isn’t a problem.

Scott and I took the test at different testing centers. We were both given a locker for our personal belongings. I’ve been to a few testing centers and never seen that before. I like being able to have the key to the locker with my belongings!

We also both got one 8.5 x 11 erasable page with a felt tip erasable marker and an eraser. I like getting more than that. I found myself erasing a lot to make space. It’s really important to figure out how to make the best use of your space on the page. I use one column for questions I want to go back to and the topic (so I can look for answers hidden in other questions or think of it later.) I use another column for “facts.” They may be things I’m reminded of during the exam. Often there are things I write down the second the exam starts. That way I don’t have to keep it memorized. For the stuff that’s hard for me to remember. And I use the bottom for actually solving problems. Like drawing what is in variables.

The testing center I went to also gave me earplugs. First time I’ve ever been handed earplugs. The irony was that it wasn’t loud! When I went to the loud testing center, I didn’t get earplugs!

Study materials

For the new topics, see my blog post on the upgrade exam beta. There are a few new objectives in this beta that weren’t in the upgrade exam beta like @Override. Also, some objectives changed scope since the Java 7 exam. Which you can see from the objectives. But there’s nothing like taking the test to make that sink it. I reviewed largely from draft chapters of our upcoming OCP 8 book.

 

Objectives

 

why I like regular expressions + who says they aren’t readable

Scott and I are working on our second book (OCP 8). I’m excited that I get to write the part about regular expressions as that is one of my favorite programming topics. Why, you ask? Because it lets you write clear and efficient code.

The scenario

For the book, I wrote an example showing how validating a simplified phone number is so much easier with a regular expression. The rules for the example were:

  1. a phone number is exactly 10 digits
  2. a phone number may contain dashes to separate the first three digits and next three digits, but not anywhere else
  3. no other characters are allowed (no parens around the area code in this example)

For example, 123-456-7890, 123-4567890 and 123456-7890 are valid. In real life, the third one wouldn’t be; we allow this typo here to be nice.  However dashes aren’t allowed in random positions. 12-45-67-890 is not a phone number.

Without regular expressions

This isn’t in the book, but i tired to write the code “the long way” to ensure it was annoying long. It was. I tried to write the code in a readable way and the best I could think of was:

private static boolean validateLong(String original) {
   String phone = original;
   // remove first dash (if present)
   if (phone.charAt(3) == '-') {
     phone = phone.substring(0, 3) + phone.substring(4);
   }
   // remove second dash (if present)
   if (phone.charAt(6) == '-') {
      phone = phone.substring(0, 6) + phone.substring(7);
   }

   // validate 10 characters left
   if (phone.length() != 10) {
      return false;
   }

   // validate only numbers left
   Set<Character> digits = new HashSet<>(Arrays.asList('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'));
   for (int i = 0; i < phone.length(); i++) {
      if (!digits.contains(phone.charAt(i))) {
         return false;
      }
   }
   return true;
   }

This is a lot of code. And to those who think regular expressions are unreadable, what do you think of the above? I don’t find it easy to see what is going on even though I wrote it. There’s just too much logic and too much detail to ensure is correct. (And no, it didn’t work on my first attempt.)

With regular expressions

Re-writing to use regular expression gives me this:

private static boolean validate(String phone) {
   String threeDigits = "\\d{3}";
   String fourDigits = "\\d{4}";
   String optionalDash = "-?";
   String regEx = threeDigits + optionalDash + threeDigits + optionalDash + fourDigits;
   return phone.matches(regEx);
}

Even if you don’t know the regular expression syntax, it should be obvious what is going on here. We look for three digits, an optional dash, three more digits, another optional dash and a final four digits.

It’s a tiny bit longer in the book version because {3} isn’t on the exam so that part is:

String threeDigits = "\\d\\d\\d";
String fourDigits = "\\d\\d\\d\\d";

Still. Way easier to read and faster to write than the original code without regular expressions. I consider regular expressions like a hammer. They aren’t the right tool for every job, but they are quite helpful when they are the right tool.

jeanne’s ocpjp java programmer II experiences

About three weeks ago, I took the OCPJP Java Programmer II beta exam.  If I pass, I become a Oracle Certified Professional (OCP) Java SE 7 Programmer.  Hmm.  If you are already an OCM (Oracle Certified Master) from the OCMEA, is that a step backwards?  Just kidding.  It’s still cool.

I don’t know how I did because I took the beta version of the exam.  I’ll edit this post and leave a comment in a few months when I do know.  (My guess is I got between 70 and 80% though.  Since the scoring of a beta depends on which questions get chosen for the real exam, my score could be a lot lower or higher.  Probably lower – I can’t imagine they’d choose all the easy questions!)

 

Edit: I got a 78%.  I can’t believe how close my estimate was!

If you took the SCJP in the “good old days” (Java 6) or earlier, you only had to take one exam to become certified.  Now you need two.  I took the OCAJP a little over a week after the OCPJP.  Advice: take the exams in the proper order.  The OCAJP is a lot easier; it will build confidence before the harder exam.

Deciding to take the test

I wrote about this on my OCAJP post.  I scheduled the exam for the last week of the beta.  (Which got extended another month after that.)  One interesting factor is that I decided to take the exam 20 days before the date I scheduled the exam.  I went in figuring I would see how well I did given a time constraint.  Which means I could have gotten a higher score had I studied more.  I do recommend you actually feel fully prepared before taking the exam so you don’t waste $300.  (The beta is only $50 so the economics work out differently.)

How were the resources I tried

  1. K&B version 5 – Granted you’d buy version 6 at this point.  (or the OCA/OCP 7 version once it is out).  Of course, get the latest version available, but this is a great book.  Covers all sorts of exam trickery, how to think about exam questions and tough questions at the end of each chapter.  It’s worth buying the version 6 book even for the 7 exam because you learn over half the material and get a feel for what types of things to study for the rest.  I have no doubt that once the version 7 book is out, it will be awesome as well.
  2. K&B SCJP 6 mock exam book – Same deal.  The extra questions helped even though some were out of scope.  I routinely got between 35 ad 45 (out of 60) questions right in a mock.  I didn’t spend a long time on the questions or treat it like a real exam though.  One note: the authors warn that the more times you see the same questions the better you do since you remember the questions.  I didn’t have this experience.  I did roughly as poorly each time I saw the questions.  I think it is because I don’t try to remember the answers and the questions all look similar.  As does the real exam for that matter.
  3. Anki – The act of creating and reviewing flashcards is what helped here and is absolutely critical to learning facts.  The time interval learning helped me optimize my time with the flashcards and manage the fact that I have 200 of them.  I’ll be writing a separate blog post on Anki and will link to it from here when it is up.
  4. epracticelabs – Deep breath.  What to say here.  It is Windows only which meant I was using my old computer.  I bought version 1.2 of the Java 7 upgrade to get some exposure to Java 7 questions since my study materials were so heavily weighted to the SCJP 5 and 6.  The “book” part wasn’t bad.  I didn’t find much value since I had already studied by the time I got there.  The mock exams were of poor quality.  I found errors in the answers, there were redundant questions and there were typos in questions.  I complained and received a refund.  I then tried version 1.3 which added another mock exam and fixed various quality issues.  Which it did.  I didn’t notice any typos in the new mock.  I did find two mock exam questions on JDBC with incorrect answers.  (I didn’t check the other topics as I like JDBC best.)  Some questions are good and others are like “which API copies a file: copy, file or move” or “is JDBC used for database code”.  There is heavier testing on API knowledge than concepts but you still need to know APIs for the exam.  Don’t rely on epracticelabs for the majority of your reviewing.  It’s an ok tool but has gaps.  In particular, it still misses a couple significant areas from the exam.  While the quality is improved from 1.2, it still has a ways to go.  I do believe they are working on it.  [Note: Since I had heard good things about epracticelabs from others I asked to try a different product in hopes this one was an anomaly.  It was.  The SCEA part 1 product was excellent content and quality.  And the CEO of epracticelabs acknowledges the quality issue in the Java 7 product and has a plan to deal with that.]
  5. BlackBeltFactory – Some helped me learn exam material (Java 7 features and SCJP mock) and others were just interesting (NIO covers pre-Java 7 NIO)
  6. Oracle tutorials (Programmer II and Upgrade 7) – there’s a lot of non-exam material to read through.  For the Java 7 parts it helped more since it wasn’t known well what the scope of the exam was.  For the “classic” material it was more effective to use the Sierra & Bates books.
  7. Well Grounded Java Developer – While it was a great review of the Java 7 features, it turned out the ones on the exam were a small percentage of what was in those chapters of the book.  Great book not a good study tool.
  8. Java 7 New Features Cookbook – Almost the same deal as the Well Grounded Java Developer.  I say almost because each recipe has a “there’s more” section which covers tricky things.  And the exam likes tricky things.  Until the actual OCPJP 7 study guides come out, this isn’t a bad way of collecting some gotchas.
If you only have one resource, I’d choose the Sierra & Bates study guide.  If you have two, I’d add the Sierra & Bates mock exam book.

My impressions of the exam

  • I don’t know if I passed, but I think it was a good exam.  I didn’t feel like I was being tested on a ton of obscure things nobody would care about.  Still tricky, but didn’t feel as obscure and felt more real.
  • Since it was a beta, there were a lot of extra questions.  Which meant there was some duplication.  Ironically this didn’t help answer the questions as the exam creators were consistent in how they asked the things I didn’t know!
  • I really liked the JDBC questions.
  • While the OCPJP and OCAJP have different objectives, the OCPJP is essentially cumulative.
  • I’m glad I finally took it.

My study plan

As an added bonus to only having three weeks to study for the exam, I was also traveling for a few days during that period.  Luckily I was somewhat familiar with the content and had already read the Java 5/6 parts of the exam materials so it was more a matter of review.

I’m listing out how I studying day by day so you can see the quantity that comes with rushing.  And that I still allowed myself to do other big tech activities.  It also shows how I tried to follow the K&B study guide suggestion to study at least 15 minutes each day.

  1. Thursday – Registered for the beta.  Printed the objectives for the OCJP 7 exam.
  2. Friday (off from work this day) – Re-read chapters 1-3 of K&B SCJP 5 study guide.
  3. Saturday – Researched and downloaded Anki – a timed flashcard program.  Re-read chapters 4-6 of K&B SCJP 5 study guide.  Did a couple of easy BlackBeltFactory exams to get some pre-reqs for their SCJP mock out of the way.
  4. Sunday – Re-read chapters 7-8 of K&B SCJP 5 study guide.  Did the handful of OCPJP sample questions on Oracle’s website.  Did the K&B master exam on CD. Also spent 6 hours migrating jforum data.
  5. Monday – Re-read chapter 9 of K&B SCJP 5 study guide.  Created iPad flashcards for Anki.
  6. Tuesday – Re-read chapter 10 of K&B SCJP 5 study guide.  Created iPad flashcards for Anki.
  7. Wednesday – On flight, took the two short mock exams in K&B SCJP 6 mock exam book.  Also took mock exam #3 but didn’t review answers.  Reviewed 60 questions from Anki.  From this point forward, I went through all the cards Anki suggested every day.  (On the flight back, I slept so I’ll leave that out here.)
  8. Thursday – Reviewed mock exam #3.  Went through SCJP Coach questions on iPad app.
  9. Friday – Started mock exam #4.  Went through more questions on SCJP Coach
  10. Saturday – 15 minutes of flashcards (bare minimum of 15 minute rule)
  11. Sunday – finished mock exam #4
  12. Monday – Read the 2 minute drills from chapters 1-4 in K&B SCJP 5 study guide (they take a lot longer than 2 minutes)
  13. Tuesday – Took BlackBeltFactory advanced Java exams that were pre-reqs to SCJP one.  Make notes and flashcards for the Java classes added on the SCJP 6.  (just NavigableMap, NavigableSet and Console.)
  14. Wednesday – Read the 2 minute drills from chapters 5-7  in K&B SCJP 5 study guide
  15. Thursday – Read the 2 minute drills from chapters 8-10  in K&B SCJP 5 study guide [If you are paying attention, I’m not a week to the exam and haven’t done one iota of study on the Java 7 material which is a substantial part of the OCPJP 7 exam.]
  16. Friday – Skimmed Oracle tutorials on Programmer II and read those on Upgrade 7 topics.
  17. Saturday – mock exam #5.  More BlackBeltFactory exams.
  18. Sunday – mock exam #5.  More BlackBeltFactory exams.  Reread Well Grounded Java Developer chapters about new Java 7 features including NIO2 and concurrency.  Tried epracticelabs java 7 upgrade exam.
  19. Monday – Re-read Java 7 New Features Cookbook parts on exam scope items.
  20. Tuesday – Finish Java 7 New Features Cookbook parts on exam scope items.