Subscribe to Stuck in an Infiniteloop        RSS Feed
-----

Oracle Certified Professional, Java SE 6 Programmer

Icon 15 Comments
This morning I passed the Java Standard Edition 6 Programmer Certified Professional Exam, aka OCPJP, aka the exam formally known as Sun Certified Java Programmer (SCJP).

The official title being: "Oracle Certified Professional, Java SE 6 Programmer"

--

While I signed a piece of paper saying I would not discuss the exam, I can share with you the prep work I did.

The book I used was fantastic. Yes, the title is wrong; yes the exam number has changed; however, the good news is, the content has not. This excellent tome is ten chapters long each with a mini drill and self test at the end of each. It also comes with two practice exams.

I went through the book once thoroughly and then two quicker sweeps and the practice tests this past week leading up to the exam. As the authors reiterate many a time, the key is to actually write code. Especially if the answer makes you go "WTF?" There was a lot of that going through the book's examples.

Coming from a C++ background some of the Generics (which are nearly worthless) can be tricky. Your hands are tied due to backwards compatibility unfortunately. Polymorphism works nearly the same. Key word being nearly.

Given some of the material it would not surprise me (now) that someone that's been using Java professionally for several years could/would fail the exam without doing some prepwork. For example, I have never had the need to use a class initializer (static or otherwise) in the following manner:

class Test{
     static { System.out.println("Static Hi!"); }
     { System.out.println("Hi!");}
     public void hello() {System.out.println("Hi from hello()!");}
     public static void main(String args){
          new Test().hello();
     }
}



Without coding it, what do you think the output would be?

Spoiler


Never ever had to use that in 4+ years. It was weird crap like the above that had me seriously regretting signing up for this test when going through the book.

--

Having that said though, diving into the minute behavior of the language was not only great for the exam, but in general for work and pleasure programming. As they say, the devil is in the details.

15 Comments On This Entry

Page 1 of 1

alke4 Icon

22 July 2011 - 03:00 PM
Congrats on passing the exam! :bananaman:
1

calebjonasson Icon

22 July 2011 - 03:07 PM
Congratulations.

Did not know you could use static like that...
1

cfoley Icon

22 July 2011 - 04:15 PM
Congratulations!

If you enjoy Java's quirks (including loads about static initialisers) check out Java Puzzlers by Bloch & Gafter.
1

Curtis Rutland Icon

22 July 2011 - 04:27 PM
That initializer seems pretty wicked. I'm not sure why you wouldn't just stuff that in the constructor, and make a static constructor (does java support those?)

Also, it's good that they don't use the same certification naming as MS does, because you'd end up with Oracle Certified Professional Developer, or OCPD.
2

KYA Icon

22 July 2011 - 04:28 PM

Curtis Rutland, on 22 July 2011 - 05:27 PM, said:

That initializer seems pretty wicked. I'm not sure why you wouldn't just stuff that in the constructor, and make a static constructor (does java support those?)


Unfortunately not. I liked that feature when I was dabbling in C#.
0

Curtis Rutland Icon

22 July 2011 - 04:38 PM
Ah, 'tis a shame. I've actually used them a few times.
0

Hiram Icon

23 July 2011 - 02:54 AM
Well, I've actually used a static initialiser before. They're pretty cool.

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
 
public class HibernateUtil 
{
   private static final SessionFactory sessionFactory;
   
   static
   {
      try 
      {   
         sessionFactory = new Configuration().configure().buildSessionFactory();
      }   
      catch (Throwable ex) 
      {   
         System.err.println("initial SessionFactory creation failed." + ex);
         throw new ExceptionInInitializerError(ex);
      }   
   }
   
   public static SessionFactory getSessionFactory()
   {
      return sessionFactory;
   }



Stuff like this is pretty useful. Giving me a static, completely accessible Hibernate session factory from anywhere is pretty cool.
1

smohd Icon

23 July 2011 - 11:36 AM
Congratulation :^:
0

smohd Icon

23 July 2011 - 11:48 AM

Curtis Rutland, on 23 July 2011 - 05:12 AM, said:

Also, it's good that they don't use the same certification naming as MS does, because you'd end up with Oracle Certified Professional Developer, or OCPD.

Haha!! and we have a good name for MCPD
0

Curtis Rutland Icon

23 July 2011 - 09:41 PM
@Hiram, in C# we can actually mark a class static, if we're only going to use it statically, and static or not, we can provide a static constructor (which behaves similarly to your static initializers). Maybe they'll bring that stuff into java one day. I've used stuff like this for constant classes, and for singletons.
0

Hiram Icon

24 July 2011 - 03:23 PM
@Curtis that's really useful! Hopefully Oracle add that to Java soon, but I doubt it. I think a "floating" static block looks really out of place in code. A static class with a static constructor is a lot cleaner.
0

n0mad Icon

24 July 2011 - 07:34 PM
Congrats :)
0

fromTheSprawl Icon

28 July 2011 - 11:14 PM
Congratulations! :)
0

ladyinblack Icon

01 August 2011 - 02:57 AM
Well, congrats on the passing of the exam.

I'm as well studying for the Oracle Certified Professional exam. I figured a few professional certifications on my resume would make it more appealing.

I have in fact seen a few code snippets with just static. What doesn't make sense to me is the last line,
new Test().hello();
I would have figured it made more sense as
new Test.hello();
But that's probably me confusing Java with C++.
0

KYA Icon

01 August 2011 - 04:54 PM
hello() is an instance method, so I have to create an instance of test new Test() before calling anything on it. If it was static it would be Test.hello(); sans new.
0
Page 1 of 1

September 2014

S M T W T F S
 1 2 3456
78910111213
14151617181920
21222324252627
282930    

Tags

    Recent Entries

    Recent Comments

    Search My Blog

    2 user(s) viewing

    2 Guests
    0 member(s)
    0 anonymous member(s)