Sunday, 29 December 2013

Our screencast about programmer certification

In order to facilitate OCPJP aspirants, we created a screencast to provide information about Oracle Java Programmer certification. In this screencast, we discuss why a programmer certification is required, what different certifications are available, some tips about exam preparation and resources to prepare for OCPJP 7 certification exam.

We hope that the readers will find the attempt useful and informative.

Screencast: Cracking Oracle Java Programmer Certification - Part I


Screencast: Cracking Oracle Java Programmer Certification - Part II

Screencast: Cracking Oracle Java Programmer Certification - Part III


Thursday, 26 December 2013

Untangle your confusion about programmer certification

Newbies in Java hear about programmer certification organized by Oracle and aspire them. However, many a times, they are not clear first, whether to go for certification, and second, which certification to target. This confusion becomes a puzzle when the newbie learns that (s)he can go for programmer certification version 6 and version 7. Here, we would like to help you to resolve the confusion.

For programmer certification (at associate and professional level), Oracle offers OCAJP 7 (Oracle Certified Associate Java Programmer) and OCPJP (Oracle Certified Professional Java Programmer) certification. There are currently three popular exams associated with OCPJP:
  • OCPJP 6 : Oracle Certified Professional Java Programmer for SE 6 (1Z0-851)
  • OCPJP 7 : Oracle Certified Professional Java Programmer for SE 7 (1Z0-804)
  • OCPJP 7 upgrade: Oracle Certified Professional Java Programmer for SE 7 upgrade exam (1Z0-805)
So, which one is appropriate for you? We prepared the following self-explanatory chart to help you; we hope it would be helpful for you in making your decision.

(1) A certification primer
(2) SCJP/OCPJP 6 or 7?

Sunday, 24 November 2013

A comprehensive guide for OCPJP 7 exam preparation

OCPJP 7 book

Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804 and 1Z0-805  is a concise, comprehensive, step-by-step, and one-stop guide for the Oracle Certified Professional Java SE 7 Programmer Exam. (Publisher: Apress)

Why an OCPJP 7 aspirant should refer our book? Here is the answer:
- Our book is the first and only book available right now for OCPJP 7 exam preparation. It covers all the exam topics for OCPJP 7 with required depth.
- First chapter (FAQs chapter) of the book clears very basic questions that one may have related with the exam. 
- Second chapter sports a pre-test which can be used to know the preparation level initially and where one needs to put more effort. 
- Each topic is explained using examples with many corner-cases covered.
- After each chapter, a set of questions are presented to quickly test what one just learnt. 
- "Points to remember" is a very interesting section that lists corner cases and tricky elements with respect to the topic. 
- The book comes with two full-size mock-tests (90 questions each) which gauge preparedness of the aspirant for the actual exam.

If you are new to Java certification, please refer this post. We offer a set of downloadable resources here. You can report a possible mistake from this erratapage.

Saturday, 23 November 2013

Oracle Java Certification Exam Preparation (for OCPJP 7 Exam)

Why Oracle Java Certification?  

Let us start with the question - why get certified? 

The reason is to differentiate yourself. The key to getting a job, hike, or promotion is to show that you deserve it! 

Getting certified is one of the means to show that you have relevant knowledge and skills:
  • Show that you have some document proof that you have relevant skills or knowledge
  • Show that you are different from others (competing with you) that you have some specialized skills or knowledge 
Getting certified also has other benefits as well: 
  • Preparing for a certification exam gives you focus on learning relevant and important topics; the certification exam date gives you a deadline so you will take learning seriously 
  • The process of preparing for the exam and actually passing the exam gives you confidence necessary for getting a job or asking for a promotion or a raise
Now you may ask, why Java certification? 
  • One obvious reason is that Java is one of the most popular programming languages on this planet. As on 17th March 2013, according to TIOBE index - the language popularity index most people refer to - listed Java as the most popular language in the world ahead of languages like C, Objective-C, C++, and C#. This popularity of Java translates to the need for more Java programmers in the IT industry. 
  • Java certifications are one of the most popular IT certifications, so potential employers or your managers will recognize this certification.
  • There is always need for high-quality Java developers and having this certification shows that you are one of those qualified Java developers 
Next, we’ll briefly discuss about the Oracle’s certification path. At a very high-level, there are four levels of certifications: Associate, Professional, Expert, and Master levels. 
  • Oracle Certified Associate: This certification shows that you have fundamental skills necessary for an IT career; it provides a strong foundation for further exams.
  • Oracle Certified Professional: This certification shows that you have professional skills and technical expertise to develop enterprise software. 
  • Oracle Certified Expert: This certification shows that you have specialized levels of skills and knowledge.
  • Oracle Certified Master: This certification shows that you have mastery or expert level of skills and knowledge.      
There are three Oracle Java exams for Java SE 7 at beginner to intermediate level.
  • Java SE 7 Programmer I: The is a beginner level exam - if you pass it you get Oracle Certified Associate Java SE 7 Programmer (OCAJP 7) certification. There are no pre-requisites for taking this exam. 
  • Java SE 7 Programmer II and Upgrade to Java SE 7 Programmer: These two are intermediate level exams - if you pass either of these exams, you will get Oracle Certified  Professional, Java SE 7 Programmer (OCPJP 7) certification. If you have older Java certifications such as SCJP 5, then you can go for Upgrade to Java SE 7 Programmer; otherwise, you need to take Java SE 7 Programmer II exam. For Java SE 7 Programmer II exam, the prerequisite is that you should have passed the OCAJP 7 exam. 
Oracle Certified Professional Java Programmer 7 (OCPJP 7) Overview

Exam topics

There are 12 exam topics for Java SE 7 Programmer II certification - 
  • Java Class Design
  • Advanced Class Design
  • Object-Oriented Design Principles
  • Generics and Collections
  • String Processing
  • Exceptions and Assertions
  • Java I/O Fundamentals
  • Java File I/O (NIO.2)
  • Building Database Applications with JDBC
  • Threads
  • Concurrency
  • Localization
However, the Upgrade to Java SE 7 Programmer has only six exam topics: 
  • Language Enhancements
  • Design Patterns
  • Java File I/O (NIO.2)
  • Building Database Applications with JDBC
  • Concurrency
  • Localization
In other words, the Upgrade to Java SE 7 Programmer assumes that you know topics such as class design because you have passed one of the earlier exams. So, the focus of the Upgrade exam is only on additional topics or Java 7 topics.  

Getting familiar with OCPJP 7 exam 

The exam has only multiple-choice questions. You will get 4 to 7 options for each question; but most questions will have four options. Note that many questions will have more than one answer to be selected - the question will clearly tell you how many options you need to select. 

The exam questions intend to test your ability to solve real-world problems. You can expect most questions to be programming-based questions. For example, given a program or code segment, the question could be to predict the behavior by selecting the expected output from the given list of options. You will also get a few conceptual questions. These questions will test your knowledge and will not have any programs in it. Examples: What are different kinds of drivers in JDBC? What are different kinds of liveness problems with threads? 

Most questions will check your knowledge of language features and their usage. They will test if you understand language features and can apply them in practical situations. But note that most questions will not be on obvious aspects of Java language features. Rather, the questions will be on nitty-gritty details or corner cases, or unusual aspects of the language. For example, you don’t just need to understand the generics feature in Java but also need to understand problems due to type-erasure in generics. 

Many questions will test your knowledge of library features and their usage. They will test if you are familiar with Java APIs and know how to use them in practical situations. You can be sure that questions will be on nitty-gritty details or corner cases, or unusual aspects of the library. For example: What does the remove() method of Deque do? (Answer: It removes the front or first element from the underlying deque instance - not the back or last element).

To summarize, the exam tests your understanding of the Java language and library and your ability to apply it for problem solving. However, note that it does not test your memory skills. Still there are few topics where you may need to remember key things. Some examples: 
  • Letters used for creating custom date and time formats (i.e., "string patterns") for use with SimpleDateFormat class
  • Characters used for forming pattern strings in regular expressions
  • Format specifiers and their meaning for use in format() method in String and in printf()
If you have done programming with time formats, regular expressions, format specifiers etc. you’ll know them; but if you are relatively new to these topics, then you need to refresh them before appearing for the exam. 

Also note that exam questions need not be exactly from the exam objectives! Any topics related to the exam objectives can come in the exam. For example, serialization and use of transient keyword is not explicitly mentioned in the OCPJP exam topic. But this topic can come in the actual exam because it is related to reading and writing streams, and one of the streams is ObjectStreams and it relates to serialization!

How to Prepare for the Exam 

Now let us discuss about preparing for the exam. 

The best way to prepare for the exam is to write lots and lots of small programs and learn from your mistakes! If possible, try taking up some small toy projects in the topics you’re new or not familiar with. This is especially important if you don’t code in Java in your regular job. 

However, it is also important to read and learn more about the language features and the library. There are some excellent resources out there in the internet freely available for you to read. 
Some tips for exam preparation 
  • When preparing for the exam, focus especially on the new features introduced in Java 7.   
  • Take a close look at the exam objectives and grade yourself from, say 1 to 10, with 10 being the highest. Prepare all the topics for which you've rated yourself as 8 or below.
  • Plan for taking your exam well in advance: look out for scheduling the exam when you’ll be free for at least a few weeks for exam preparation; avoid last minute rush to prepare for the exam. 
How to register for the exam?

You have three options:
  • You can register and pay at the Pearson VUE website (this is the option most exam takers choose).  
  • You can buy exam voucher from Oracle and then register yourself in Pearson VUE website. 
  • You can register and pay in the Oracle Testing Center (OTC). 
Before we end 

Do checkout our OCPJP 7 book which is the only book available in the market for exam preparation. 

That’s all, and wishing you all the best for cracking the OCPJP 7 exam with ease. 

Thursday, 21 November 2013 2013 Job Survey results: Java/J2EE developers topmost in demand!

You can read the whole report here:

Extract from this report:
What’s not new is the continuing demand for developers – the closer to the application, the stronger the job market. Atop the priorities list for the second consecutive year: Hiring Java/J2EE developers. More than one in five of the 77,000 jobs posted on Dice contained some mention of the need for java know-how. The bottom line: If you’re looking to hire veteran Java-fluent talent, expect plenty of competition for the human equivalent of the iPad Mini, this year’s “tech gadget everyone has to have.”

Bottom-line: Getting certified in Java could be one of the ways to differentiate yourself in the high-demand market for Java developers!

Tuesday, 5 November 2013

Winners of our contest

We announced a contest two weeks back where we invited our readers to write reviews and win free printed copies of our book (see the relevant post). The contest got over on 3rd Nov 2013. Overall it attracted decent participation. Based on the reviews, we are happy to announce three winners of the contest:
  • Tomas Petras Rupsys (from Lithuania)
  • Carl Clemens (from USA)
  • Ujwala (from India)
Congratulations to winners!!

We are in the process of sending them printed copies of our book; they will receive the book in a few days. Thanks to all the participants who had participated in the contest. 


Monday, 28 October 2013

Where to get OCPJP 7 mock exams?

One of the most frequently asked questions on OCPJP 7 - IZ0-804 exam preparation is this: Where can I get mock exams, preferably with exam simulator?

Of course, there are 300+ questions in our OCPJP 7 book (including 2 full-length mock tests). Hence, the book is the source that we would like to recommend.

We found that there are many resources where you can get (mostly commercial) mock tests and use simulators to try them out. Please note that there are numerous free mock exams available in the internet, but when we checked, all of them were SCJP 5/6 mock exams; they are yet to support OCPJP 7 exams. For a detailed list of SCJP mock exams, check this link in coderanch (where else :-))  

For OCPJP 7, we found that there is no single place where a list is maintained. Hence, we have started collecting a list; here is an initial list to start with:


(To our surprise, we did not find any completely free OCPJP 7 mock exams. If you find any, please let us know, and we'll update this list)

  • Kaplan SelfTest (Oracle authorized): 170 questions, price starts from $69 
  • Transcender (Oracle authorized): 190 questions, price starts from $109 
  • WhizLabs: OCPJP 7 exam simulator (700 questions - 5 full-length mock exams) -- Rs. 1500 (10% discount usually available) 
  • EPractizeLabs: OCPJP 7 online training -- $399 (50% discount) => $199 (announcement - training not released yet). OCPJP 7 study guide + mock exam questions -- $30 (720 questions) 
  • Enthuware: $9.95 for question bank with around 500 questions. 
  • TechFAQ360, JavaCert, CertChamp: (4 mock tests + lots of sample questions) (strangely, the descriptions of the exam appeared to be the same so clubbed these three together!)  

Are we missing out any? If so, please post it as a comment here or contact us.

Disclaimer: We are sharing these links in our blog because many of our readers are interested in knowing about the available mock tests. We have NO personal experience or contacts whatsoever with any of these mock exam providers; so we have no recommendations. 

Sunday, 27 October 2013

Connect with us

We would like to be connected with our readers. Initially, we created this blog to serve the intent. To further improve communication between our readers and us, we have created a Facebook page, and a Linkedin group along with our personal twitter accounts. We invite our readers to connect with us via all of these social mediums so that we get connected and share information mutually.

Twitter: @GSamarthyam @Sharma__Tushar
Facebook page: OCPJP 7
Linkedin group: OCPJP

Sunday, 20 October 2013

Participate in the contest and win free copies of our book

Here is the excellent opportunity for all our readers to win free printed copies of our book. All you have to do is write review for our book on Amazon (.com or any of the country-specific Amazon site) and you stand a chance to win a free copy of our book.

Readers can participate in this contest by writing a review of our book on any of the Amazon site. Once the review is online, you need to send a mail to us ( to complete the participation. After the contest period, we will choose four best reviews (in terms of details, good things about the book, things that could have been improved, etc.) and we will mail printed books to the winners. To increase your chances to win a book, write a detailed informative review for our book.

There are total four printed books to grab. Readers from all over the world (except India) have a chance to win two copies of our book. Readers from India also have a chance to win two copies. 

So what you are waiting for? The contest period is 20th Oct 2013 to 3rd Nov 2013. Hurry!!

Sunday, 6 October 2013 offers our book in just Rs 599

Great news for all OCPJP 7 aspirants residing in India. Our book Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804 and 1Z0-805-A Comprehensive OCPJP 7 Certification Guide is available at in just Rs 599. This is the excellent opportunity to buy the printed book in a very cost-effective way. 

Please note that the book sold by is the revised version (in which first set of errata is fixed).

Flipkart also sells the book; however, the cost-effective print is out of stock on the shopping portal.

Friday, 20 September 2013

Productive Programming with Groovy

Are you a Java programmer having wrist pain typing a lot (yes, I have!)? Does your mind keep swinging from loving to hating Java? Do you want to become more productive without leaving your world of Java? If so, this presentation is for you. I have been experimenting with Groovy for the last three months and I'm loving it - I am not going back to programming in plan old Java anymore. I'm attaching the full source code (as a .zip file) so that you can try them out on your own. Have fun! 

Friday, 13 September 2013

How much do you know about smells in design?

Do you know that there are more than 500 design smells documented in literature or reported by designers? Do you know that all smells could be viewed as violation of underlying design principles? Do you need a ready catalog of design smells that is grounded on research and relevant for practice? 

Interested? Check the results of our research work on design smells and how the results can help you in practice. 

This presentation summarizes research behind our design smells work:

Our original paper is here: 

This presentation is practical - it follows an example driven approach for design smells:

Hope you enjoy reading them! And yes, please do share your thoughts.

Latest release of the book fixes reported errors in the book!

We took up the task of writing the book in an incredibly tight schedule. We wanted the book to be out as soon as the beta exam becomes the final exam, and we missed that deadline only by a month or so. Given the fact that both of us (Tushar and myself) have a full-time demanding job, hyperactive kids in our respective homes, and short deadlines, we're extremely happy that our book came out to the market as the first book on OCPJP 7 exam preparation. 

With the tight schedule, we couldn't get much time for reviews and rigorous checks, and quite a few mistakes slipped into the production version of the book - that is the major criticism of our book. We are thankful to our readers who were supportive of us as well as reported bugs. Now, all the known mistakes are fixed in the book and the updated version is available in ebook form and Print-On-Demand books; for the print version, for the further reprints, this updated version will be available. We thank the Apress team for helping us in updating the book and making it available for all the resellers. 

Our hearty thanks to the all the readers who were patient with us and helped us by reporting the errors in the errata page for the book in this blog. We've copied the image from the book acknowledgement section of the book (if we have missed anyone in this list, we are sorry for that and please do let us know): 

Note that the book in its current form is quite comprehensive, covers almost all topics in required depth, and uses an example-driven approach which makes the concepts easier to understand. Given the fact that this is the only book (to our knowledge) to *prepare* for OCPJP 7 exam available in the market, we hope that this updated version is very helpful to our readers. 

Monday, 9 September 2013

Revised cost for OCPJP 7 exam

Good news for all OCPJP 7 aspirants. Oracle has brought down the exam cost for OCPJP 7 exam. The revised exam cost (for 1Z0-804) is $245 (thus, you save $55). Here is the link to the Oracle site.
It is applicable for OCPJP upgrade exam i.e. 1Z0-805 too. Check out this link for details.

Cheers :)

Tuesday, 20 August 2013

Participate in CodeRanch discussion and win a copy of OCPJP7 book!

Forwarding the mail from Java Ranch Moose (slight editing to save space):

---------- Forwarded message ----------
From: Java Ranch Moose <>
Date: Tue, Aug 20, 2013 at 9:37 AM
Subject: Book Promo: "Oracle Certified Professional Java SE 7 Programmer Exams" & A Choice of "Agile and PMP Certification" Products
To: Java Ranch Moose <>

We are thrilled to have S G Ganesh & Tushar Sharma on the ranch to promote
the book "Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804
and 1Z0-805: A Comprehensive OCPJP 7 Certification Guide".

The promotion will be held in the Programmer Certification (SCJP/OCPJP)
forum which can be found here:

Participate in this week's giveaway by asking S G Ganesh & Tushar Sharma
a question or two and you may win a copy of the book!

The giveaway starts on Tuesday, August 20th 2013.
The drawing will be held on Friday, August 23rd 2013.

For more info or if you're plumb tired of getting this info, visit:

---------- End Forwarded message ----------

Congratulations to all the four winners :-) 

August 20Oracle Certified Professional Java SE 7 Programmer Exams 1Z0-804 and 1Z0-805: A Comprehensive OCPJP 7 Certification GuideS G Ganesh & Tushar SharmaApressAlam Ameghino, Fakih Karademir, S Gaurav, Mphatheleni Ernest Matidze

Sunday, 4 August 2013

Updated exam topics for OCPJP 7

Recently, Oracle has updated the exam topics for OCPJP 7 exam. The intention is to clarify the scope of the exam.

You can download the exam topics from here.

Tuesday, 30 July 2013

Understanding IllegalThreadStateException, IllegalMonitorStateException and thread states

There was a question on IllegalMonitorStateException and thread states in CodeRanch ( Since it is a general topic of interest to most OCPJP7 aspirants, I'm posting the expanded version of the answer I gave as blog entry here.  

Basic thread states 

A thread has various states during its lifetime. Three basic thread states to understand are – new, runnable and terminated. We will discuss more thread states a bit later. 

A program can access the state of the thread using Thread.State enumeration. The Thread class has the getState() instance method which returns the current state of the thread. Here is an example: 

class BasicThreadStates extends Thread {  
    public static void main(String []s) throws Exception {  
        Thread t = new Thread(new BasicThreadStates());  
        System.out.println("Just after creating thread; \n" +   
                "   The thread state is: " + t.getState());   
        System.out.println("Just after calling t.start(); \n" +   
                "   The thread state is: " + t.getState());  
        System.out.println("Just after main calling t.join(); \n" +   
                "   The thread state is: " + t.getState());  

This program prints: 

Just after creating thread;   
    The thread state is: NEW  
Just after calling t.start();   
    The thread state is: RUNNABLE  
Just after main calling t.join();   

    The thread state is: TERMINATED  

Just after the creation of the thread and just before calling the start() method on that thread, the thread is in the new state. After calling the start() method, the thread is ready to run or is in the running state (which we cannot determine); so it is in runnable state. From the main() method, we are calling t.join(). The main() method waits for the thread t to die. So once the statement t.join() successfully gets executed by main() thread, it means that the thread t has died or terminated. So, the thread is in the terminated state now. 

A word of advice: be careful about accessing the thread states using the getState() method. Why? By the time you acquire information on a thread state and print it, the state could have changed! I know the last statements could be confusing. To understand the problem with getting thread state information using the getState() method, consider the previous example. In one sample run of the same program, it printed the following: 

Just after creating thread;   
        The thread state is: NEW  
Just after calling t.start();   
        The thread state is: TERMINATED  
Just after main calling t.join();   

        The thread state is: TERMINATED  

Note the red italicized part of the output, the statement after printing “Just after calling t.start();”. In the initial output, we got the thread state (as expected) as RUNNABLE state. However, in another execution of the same program without any change, it printed the state as TERMINATED. Why? In this case, the thread is dead before we could get a chance to check it and print its status! [Note that we have not implemented the run() method in the BasicThreadStates class, so the default implementation of the run() method does nothing, and terminates quickly.] 

More thread states 

A thread can also be in blocked, waiting, timed_waiting states—which we’ll discuss now. I've attached a figure with this post which shows how and when the state transitions typically happen for these six states. You can use Thread.State enumeration which has the list of possible thread states. Here is a simple program that prints the value of the states in this enumeration: 

class ThreadStatesEnumeration {  
    public static void main(String []s) {  
        for(Thread.State state : Thread.State.values()){  


It prints: 


Now let us discuss exceptions. 


Here is a program that throws IllegalThreadStateException

class ThreadStateProblem {
                public static void main(String []s) {
                                Thread thread = new Thread();

The program fails with this stack trace:

Exception in thread "main" java.lang.IllegalThreadStateException
                at java.lang.Thread.start(Unknown Source)
                at ThreadStateProblem.main(

Here, we are trying to start a thread that has already started. When we call start(), the thread moves to “new” state. There is no proper state transition from “new” state if we call start() again; so the JVM throws IllegalThreadStateException


Here is a program that results in a IllegalMonitorStateException: 

class ThreadStateProblem extends Thread {
                public void run() {
                                try {
                                catch(InterruptedException ie) {
                                                // its okay to ignore this exception since we’re not
                                                // interrupting exceptions in this code
                public static void main(String []s) {
                                new ThreadStateProblem().start();

This program crashes like this:

Exception in thread "Thread-0" java.lang.IllegalMonitorStateException
                at java.lang.Object.wait(Native Method)

The wait(int) method (with or without timeout value) should be called only after acquiring a lock: a wait() call adds the thread to the waiting queue of the acquired lock. If we don’t do that, there is no proper transition from the running state to timed_waiting (or waiting state in case timeout value in not given) can happen. So, the program crashes by throwing IllegalMonitorStateException exception.

The correct fix is to acquire the lock before calling wait(). In this case, we can declare the run() method synchronized:

synchronized public void run() {
                try {
                catch(InterruptedException ie) {
                                // its okay to ignore this exception since we’re not
                                // interrupting exceptions in this code

Since the run() method is synchronized, the wait() will add itself to the this object reference lock. Since there is no one calling the notify()/notifyAll() method, after timeout of 1 second (1000 milliseconds) is over, it will return from the run() method. So, the wait(1000); statement behaves almost like sleep(1000) statement; the difference is that calling wait() releases the lock on this object when it waits while sleep() call will not release the lock when it sleeps.

So, the key observation is that: We must call wait and notify/notifyAll only after acquiring the relevant lock. 

Difference between these exceptions 

If you already did not recognize,  IllegalThreadStateException is different from IllegalMonitorStateException. 

Here is the description of IllegalThreadStateException from JavaDoc: "Thrown to indicate that a thread is not in an appropriate state for the requested operation. See, for example, the suspend and resume methods in class Thread." 

Here is the description of IllegalMonitorStateException from JavaDoc: "Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor." 

In both the cases, we need to be careful about thread states. In case of IllegalThreadStateException, it is about attempted illegal transition in thread states (and is nothing to do with locks). Whereas with IllegalMonitorStateException, it is about holding a lock - it occurs when attempting to call methods such as wait or  notify on an object that does not hold the lock.