Java Certification Tips And Tricks

In this Java Certification Tips Tricks, I have provided a very simple and powerful techniques how to prepare for OCA certification exam with very minimal preparation. If you are already a java professional and you have limited time after your day job, you must follow this plan to crack the exam in 30-60-90 days. Lets discuss the overall strategy and tips/tricks to catch most popular java certification exam.

[Read the full java certification syllabus article by clicking here & Chapter by Chapter Tutorial ]

Studying for the Certification Test

Before you even sign up and take the test, you need to study the material. Studying includesthe following tasks:

  1. Create a study plan.
  2. Read the Study Guide material.
  3. Create and run sample applications.
  4. Solve the Review Questions at the end of each chapter.
  5. Create flashcards and/or use the ones weve provided.
  6. Take the three practice exams.

We have published chapter by chapter article corresponding exam objectives, to make it easierto assimilate. The earlier topics on syntax and operators are especially important sincethey are used throughout the code samples on the exam. Unless we explicitly stated somethingwas out of scope for the exam, you will be required to have a strong understanding ofall the information in this book.

Creating a Study Plan

Rome wasnt built in a day, so you shouldnt attempt to study for only one day. Even if youhave been certified with a previous version of Java, the new test includes features and componentsunique to Java 8 that are covered in this text.Once you have decided to take the test, which we assume you have already since yourereading this book, you should construct a study plan that fits with your schedule. We recommendyou set aside some amount of time each day, even if its just a few minutes duringlunch, to read or practice for the exam. The idea is to keep your momentum going throughoutthe exam preparation process. The more consistent you are in how you study, the betterprepared you will be for the exam. Try to avoid taking a few days or weeks off from studying,or youre likely to spend a lot of time relearning existing material instead of moving onto new material.

Lets say you begin studying on January 1. Assuming you allot two weeks per chapter,we constructed a study plan in Table B.1 that you can use as a schedule throughout thestudy process. Of course, if youre new to Java, two weeks per chapter may not be enough;if youre an experienced Java developer, you may only need a few days per topic.

Java Certification Sample Study Plan

Your own study plan will vary based on your familiarity with Java, your personal andwork schedule, and your learning abilities. The idea is to create a plan early on that hasself-imposed deadlines that you can follow throughout the studying process. When someone asks how youre doing preparing for the exam, you should have a strong sense of whatyouve learned so far, what youre currently studying, and how many weeks you need to beprepared to the take the exam.

Creating and Running Sample Applications

Although some people can learn Java just by reading a textbook, thats not how we recommend you study for a certification exam. We want you to be writing your own Java sampleapplications throughout this book so that you dont just learn the material but you also understand the material. For example, it may not be obvious why the following line of codedoes not compile, but if you try to compile it yourself, the Java compiler will tell you theproblem.

float value = 102.0; // DOES NOT COMPILE

In this section, we will discuss how to test Java code and the tools available to assist youin this process.

Tips Tricks -1

A lot of people post on the CodeRanch.com forum asking, Why does thiscode not compile? and we encourage you to post the compiler error messageanytime you need help. We recommend you also read the compilermessage when posting, since it may provide meaningful information aboutwhy the code failed to compile. In the previous example, the compiler failed to compile with the messageType mismatch: cannot convert from double to float. This messageindicates that we are trying to convert a double value, 102.0, to afloat variable reference using an implicit cast. If we add an explicit castto (float) or change the value to 102.0f, the code will compile without issue.

Sample Test Class

Throughout the java certification articles, I have presented numerous code snippets and ask you whether theyllcompile and what their output will be. These snippets are designed to be placed insidea simple Java application that starts, executes the code, and terminates. As described inarticle, Java Building Blocks, you can accomplish this by compiling and running apublic class containing a public static void main(String[] args) method, such as thefollowing:

public class TestClass {
public static void main(String[] args) {
  // Add test code here
  // Add any print statements here
  System.out.println("Hello World!");
 }
}

This application isnt particularly interestingit just outputs Hello World and exits.That said, we can insert many of the code snippets present in this book in the main()method to determine if the code compiles, as well as what the code outputs when it does compile. We strongly recommend you become familiar with this sample application, somuch so that you could write it from memory, without the comments.

We recommend that while reading this book you make note of any sections that youdo not fully understand and revisit them when in front of a computer screen with a Javacompiler and Java runtime. You should start by copying the code snippet into your test class, and then try experimenting with the code as much as possible. For example, we indicatedthe previous sample line of code would not compile, but would any of the followingcompile?

float value1 = 102;
float value2 = (int)102.0;
float value3 = 1f * 0.0;
float value4 = 1f * (short)0.0;
float value5 = 1f * (boolean)0;

Try out these samples on your computer and see if the result matches your expectation.Heres a hint: Two of these fives lines will not compile.

Identifying Your Weakest Link

The best advice we can give you to do well on the exam is to practice writing sample applicationsthat push the limits of what you already know, as much and as often as possible.For example, if the previous samples with float values were too difficult for you, then youshould spend even more time studying numeric promotion and casting expressions.Prior to taking the OCA exam, you may already be an experienced Java developer,but there is a difference between being able to write Java code and being a certified Javadeveloper. For example, you might go years without writing a ternary expression or using an abstract class, but that does not mean they are not important features of the Java language.You may also be unaware of some of the more complex features that exist within the Java language. On top of that, there are new features to Java 8, such as lambda expressionsand default interface methods, which as of this writing very few professional softwaredevelopers are using. The Review Questions in each chapter are designed to help you hone in on those featuresof the Java language that you may be weak in and that are required knowledge for theexam. For each chapter, you should note which questions you got wrong, understand why you got them wrong, and study those areas even more. Often, the reason you got a question wrong on the exam is that you did not fully understandthe concept. Many topics in Java have subtle rules that you often need to see foryourself to truly understand. For example, you cannot write a class that implements two interfaces that define the same default method unless you override the default method in the class. Writing and attempting to compile your own sample interfaces and classes that referencethe default method may illuminate this concept far better than we could ever explain it. Finally, we find developers who practice writing code while studying for the Java certification tend to write better Java code in their professional career. Anyone can write a Javaclass that can compile, but just because a class compiles does not mean it is well designed. For example, imagine a class where all class methods and variables were declared public,simply because the developer did not understand the other access modifiers, such as protectedand private. Studying for the certification helps you to learn those features thatmay be applicable in your daily coding experience but that you never knew existed withinthe Java language.

Taking the Test

Studying how to take a test can be just as important as the studying the material itself. Forexample, you could answer every question correctly, but only make it halfway through theexam, resulting in a failing score! If youre not historically a good test taker, or youve nevertaken a certification exam before, we recommend you read this section because it containsnotes that are relevant to many software certification exams.

Understanding the Question

The majority of questions on the exam will contain code snippets and ask you to answerquestions about them. For those containing code snippets, the number one question we recommendyou answer before attempting to solve the question is: Does the code compile? It sounds simple but many people dive into answering the question without checkingwhether or not the code actually compiles. If you can determine whether or not a particularset of code compiles, and what line or lines cause it to not compile, answering the question often becomes easy.

Checking the Answers

To determine whether the code will compile, you should briefly review the answer choicesto see what options are available. If there are no choices of the form Code does not compile,then you can be reasonably assured all the lines of the code will compile and you donot need to spend time checking syntax. These questions are often, but not always, amongthe easiest questions because you can skip determining whether the code compiles andinstead focus on what it does. If the answer choices do include some answers of the form Does not compile due to line5, you should immediately focus on those lines and determine whether they compile. Forexample, take a look at the answer choices for the following question:

  1. What is the output of the following code?
    • Code Omitted -
      A. Monday
      B. Tuesday
      C. Friday
      D. The code does not compile due to line 4.

E. The code does not compile due to line 6. The answer choices act as a guide instructing you to focus on line 4 or 6 for compilationerrors. If the question indicates only one answer choice is allowed, it also tells you atmost only one line of code contains a compilation problem and the other line is correct. Although the reason line 4 or 6 may not compile could be related to other lines of code, thekey is that those other lines do not throw compiler errors themselves. By quickly browsingthe list of answers, you can save time by focusing only on those lines of code that are possiblecandidates for not compiling. If you are able to identify a line of code that does not compile, you will be able to finishthe question a lot quicker. Often, the most difficult questions are the ones where the codedoes in fact compile, but one of the answer choices is Does not compile without indicatingany line numbers. In these situations, you will have to spend extra time verifying thateach and every line compiles. If they are taking too much time, we recommend markingthese for Review and coming back to them later.

Determining What the Question Is Asking

A lot of times, a question may appear to be asking one thing but will actually be asking another. For example, the following question may appear to be asking about method overloading and abstract classes:
12. What is the output of the following code?
1: abstract class Mammal {
2:    protected boolean hasFur() { return false; }
3: }
4: class Capybara implements Mammal {
5:    public boolean hasFur() { return true; }
6:    public static void main(String[] args) {
7:    System.out.println(new Capybara().hasFur());
8: }
9: }
It turns out this question is a lot simpler than it looks. A class cannot implement anotherclassit can only extend another classso line 4 will cause the code to fail to compile.If you notice this compiler problem early on, youll likely be able to answer this questionquickly and easily.

Taking Advantage of Context Clues

Lets face itthere will be things youre likely to forget on the day of the exam. Betweenbeing nervous about taking the test and being a bit overtired when you read a particularchapter, youre likely to encounter at least one question where you do not have a high degree of confidence. Luckily, you do not need to score a perfect 100% to pass.One advanced test-taking skill that can come in handy is to use information from onequestion to help answer another. For example, we mentioned in an earlier section that you can assume a questions code block will compile and run if Does not compile and Throw an exception at runtime are not available in the list of answers. If you have apiece of code that you know compiles and a related piece of code that youre not so sure about, you can use information from the former question to help solve the latter question. Use a similar strategy when a question asks which single line will not compile. If youreable to determine the line that does not compile with some degree of confidence, youcan use the remaining code that you know does compile as a guide to help answer other questions.By using context clues of other questions on the exam, you may be able to more easilysolve questions that you are unsure about.

Reviewing Common Compiler Issues

The following is a brief list of common things to look for when trying to determine whethercode compiles. Bear in mind that this is only a partial list. We recommend you review eachchapter for a comprehensive list of reasons that code will not compile. Also, if you have notfinished reading the book, you should set aside this list and return to it when you are preparingto take the exam.
  1. Keep an eye out for all reserved words. [Java Building Blocks]
  2. Verify brackets{}and parentheses()are being used correctly. [Java Building Blocks]
  3. Verify new is used appropriately for creating objects. [Java Building Blocks]
  4. Ignore all line indentation especially with if-then statements that do not use brackets{}. [Operators and Statements]
  5. Make sure operators use compatible data types, such as the logical complement operator(!) only applied to boolean values, and arithmetic operators (+, -, ++, --) only applied to numeric values. [Chapter :Operators and Statements]
  6. For any numeric operators, check for automatic numeric promotion and order or operationwhen evaluating an expression. [Chapter :Operators and Statements]
  7. Verify switch statements use acceptable data types. [Chapter :Operators and Statements]
  8. Remember == is not the same as equals(). [Chapter :Core API Design]
  9. String values are immutable. [Chapter :Core API Design]
  10. Non-void methods must return a value that matches or is a subclass of the return typeof the method. [Chapter :Java Class Design]
  11. If two classes are involved, make sure access modifiers allow proper access of variablesand methods. [Chapter :Java Class Design]
  12. Nonstatic methods and variables require an object instance to access. [Chapter :Java Class Design]
  13. If a class is missing a default no-argument constructor or the provided constructors donot explicitly call super(), assume the compiler will automatically insert them. [Chapter :Java Class Design]
  14. Make sure abstract methods do not define an implementation, and likewise concretemethods always define an implementation. [Chapter :Java Class Design]
  15. You implement an interface and extend a class. [Chapter :Java Class Design]
  16. A class can be cast to a reference of any superclass it inherits from or interface it implements.[Chapter :Java Class Design]
  17. Checked exceptions must be caught; unchecked exceptions may be caught but do notneed to be. [Chapter :Java Exception & More]
  18. try blocks require a catch and/or finally block for the OCA exam. [Chapter :Java Exception & More]
Once youve determined that the code does in fact compile,proceed with tracing the application logic and trying to determine what the code actuallydoes.

Tips Tricks No 2

Although you arent allowed to bring any written notes with you into theexam, youre allowed to write things down you remember at the start ofthe exam on the provided writing material. If theres a particular facet ofthe Java language that you have difficulty remembering, try memorisingit before the exam and write it down as soon as the exam starts. You canthen use it as a guide for the rest of the exam. Of course, this strategy onlyworks for a handful of topics, since theres a limit to what youre likely to remember in a short time. For example, you may have trouble remembering the list of acceptabledata types in switch statements. If so, we recommend you memorise thatinformation before the exam and write it down as soon as the exam startsfor use in various questions.

Understanding Relationships Between Answers

The exam writers, as well as the writers of this book, are fond of answers that are relatedto each other. We can apply the process of elimination to remove entire sets of answersfrom selection, not just a single answer. For example, take a look at the following question: 22. What is the output of the following application?
3: int x = 0;
4: while(++x  5) { x+=1; }
5: String message = x  5 ? "Greater than" : "Less Than";
6: System.out.println(message+","+x);

A. Greater than,5
B. Greater than,6
C. Greater than,7
D. Less than,5

E. Less than,6 F. Less than,7 In this question, notice that half of the answers output Greater than, whereas the otherhalf output Less than. Based on the code, as well as the answers available, the questioncannot output both values. That means if you can determine what the ternary expression on line 5 evaluates to, you can eliminate half the answers! You might also notice that this particular question does not include any Does not compileor Code throws an exception at runtime answers, meaning you can be assured thissnippet of code does compile and run without issue. If you have a question similar to this, you can compare the syntax and use this as a guide for solving other related questions.

Optimizing Your Time

One of the most difficult test-taking skills to master is balancing your time on the exam.Although Oracle often varies the precise number of questions on the exam and the amountof time you have to answer them, the general rule of thumb is that you have about one andhalf minutes per question. Of course, it can be stressful to frequently look at the time remaining while taking theexam, so the key is pacing yourself. Some questions will take you longer than two minutesto solve, but hopefully others will only take less than a minute. The more time you save onthe easier questions, the more time youll have for the harder questions.

Checking the Time Remaining

The exam software includes a clock that tells you the amount of time you have left onthe exam. We dont recommend checking the clock after each and every question to determineyour pace. After all, doing such a calculation will waste time and probably make you nervous and stressed out. We do recommend you check the time remaining at certain pointswhile taking the exam to determine whether you should try to increase your pace. For example, if the exam lasts two hours and is 90 questions long, the following wouldbe a good pace to try to keep.
  • 120 Minutes Remaining: Start exam.
  • 90 Minutes Remaining: One third of the exam finished.
  • Taking the Test 365
  • 60 Minutes Remaining: Two thirds of the exam finished.
  • 30 Minutes Remaining: First pass of all questions complete.
  • 5 Minutes Remaining: Finished reviewing all questions marked for Review. Selectanswers to all questions left blank.
As youre taking the exam you may realise youre falling behind. In this scenario, youneed to start allotting less time per question, which may involve more guessing, or youllend up with some questions that you never even answered. As discussed in the previous section,guessing an answer to a question is better than not answering the question at all.

Skipping Hard Questions

If you do find you are having difficulty with a particular set of questions, just skip them.The exam provides a feature to mark questions for Review that you can later come backto. Remember that all questions on the exam, easy or difficult, are weighted the same. It isa far better use of your time to spend five minutes answering ten easy questions than thesame amount of time answering one difficult question. You might come to a question that looks difficult and immediately realise it is going totake a lot of time. In this case, skip it before even starting on it. You can save the most difficult problems for the end so that you can get all the easy ones solved early on. Of course, you shouldnt mark every question for Review, so use that sparingly. For example, if youonly need 30 more seconds to solve a specific question, it is better to finish it so you do nothave to come back to it later. The trick is to not get stuck on a difficult question for a longperiod of time.

Improving Your Test-Taking Speed

Answering certification exam questions quickly does not come naturally to most people.It takes a bit of practice and skill to look at a question, a code sample, and 46 answers,and be able to answer it within a minute or two. The best way to practice is to keep solving the review questions at the end of each chapter until you can read, understand, and answerthem in under a minute. Once youve completed all of the material and practiced with the review questionsenough that you can answer them quickly and correctly, you should try one of the three60-question practice exams that come with this Study Guide. You should treat it like the real exam, setting aside two hours and finishing it in one sitting. Although we recommend you try to avoid taking the practice exams so much that youmemorize the questions and answers, we do recommend you keep taking them until youcan finish each practice exam in under two hours. Remember not to move on to the next one until you can pass the previous exam in the allotted time. If not, study more and goback to drilling on the Review Questions. The idea is that you want to be good at quicklyreading through the question, honing in on the key concept the question is asking, and being able to select the answer that best represents it.

All OCJP Java Certification Tutorials

  1. Oracle (OCJP) Java Certification Exam
  2. Java Building Blocks Java 8 Certification
  3. Operators And Statements
  4. Java Core API
  5. Java Class Design
  6. Java Exception
  7. Java Try-Catch Block
  8. Exceptional Handling in Java
  9. Common Exception in Java