Your guide to crack the OCPJP 8 exam

Menu

Tag Archive | apress

Oracle’s Java certifications are one of the most sought-after certifications in the IT world. I am one of the most viewed writers on Quora forum for the topic “Oracle certifications”. In this article myself and Ganesh have compiled common questions that were asked in this forum and also included the questions that were asked during our bookpromotion in CodeRanch.

FAQ #1. Why should I get certified?

Getting certified has many advantages:

It gives focus on learning the new language and library features (such as lambdas and stream API in Java 8)

It helps us understand nitty-gritty details of the language and library features

Differentiate ourselves from others who are equally knowledgeable

Etc.

Since preparing for certification requires focus, energy and effort, clearing it shows to the prospective employer that we can deal with real-world problems in the same way.

FAQ #2. Is OCJP certification required for a job in Java?

If you are getting certified only to get a job in Java, then note that this certification will not guarantee you a job. Also, most Java job openings do not demand the certification. Hence, the simple answer is “No”, you do not require a certification to get a job in Java.

However, having a certification will make you stand out of the crowd. Employers appreciate when they come across people taking the initiative and clearing the certification which shows that the candidate has relevant knowledge and skills.

Having said that, preparing for the certification you help you gain knowledge, learn the latest changes to the Java language, and improves your programming skill which will help you in your career path.

FAQ #3.Can you provide details of Oracle’s associate and professional exams for Java 8?

The OCAJP 8 exam (Oracle Certified Associate Java Programmer certification, exam number 1Z0-808) is mainly meant for entry-level Java developers. When you pass this exam, it demonstrates that you have a strong foundation in Java.

The OCPJP 8 exam (Oracle Certified Professional Java Programmer certification, exam number IZ0-809) is meant for professional Java developers. When you pass this exam, it demonstrates that you can use a wide range of core Java features (especially the ones added in Java 8) in your regular work for solving real-world problems.

More details about exam topics, cost, pass percentage and number of questions is available here:

FAQ #4.Can you compare the specifications of the exams targeting OCAJP 8 and OCPJP 8 certifications? Also, I have the Java SE 6 certification and I want to get Java SE 8 certification. Which exam should I take?

Please check this comparison table that compares OCA and OCP SE 8 exams. Since you already have the Java SE 6 certification, you need to take the 1Z0-813 certification exam. The exam details and exam topics are available from Oracle website here. The exam topics for 1Z0-813 are:

Language Enhancements

Concurrency

Localization

Java File I/O (NIO.2)

Lambda

Java Collections

Java Streams

All these topics and sub-topics are covered in detail in our OCP8 book. Our book does not have a practice exam dedicated to 1Z0-813, but there are good online exams available (from Kaplan, Enthuware, etc).

FAQ #5.OCAJP 8 certification is a prerequisite for OCPJP 8 certification. Does that mean that I have to *take* the OCAJP8 exam before I can take the OCPJP8 exam?

No, requirements for certification may be met in any order. You may take the OCPJP 8 exam before you take the OCAJP 8 exam, but you will not be granted the OCPJP certification until you have passed both the 1Z0-808 and 1Z0-809 exams.

FAQ #6.How does the OCPJP 8 exam differ from the older OCPJP 7 exam?

When compared to the exam topics in OCPJP 7 exam, the OCPJP 8 exam is updated with topics added in the Java SE 8 release: lambda functions, Java built-in functional interfaces, stream API (including parallel streams), and date and time API, and other important changes to the Java library.

FAQ #7. Should I take the OCPJP8 exam or earlier versions such as the OCPJP 7 exam?

Although you can still take exams for older certifications such as OCPJP 7, to remain relevant and competent, we suggest certification aspirants to go with latest certification i.e., in this case Java 8 certification.

Java documentation: The Java API documentation is a mine of information. This documentation is available online (see http://docs.oracle.com/javase/8/docs/api/ ) and is shipped as part of the Java SDK. If you don’t have immediate Internet access, you may find javac’s -Xprint option handy. For example, to print the textual representation of String class, type the fully qualified name, as in javac -Xprint java.lang.String This will print the list of members in String class on the console.

We have put up concise list of URLs on on this web page (https://ocpjava.wordpress.com/) on how to get started, list of forums where you can get your questions clarified, videos, articles and presentations for OCPJP exam preparation here Java SE 8 certification.

Read, code, read, code! Cycle back and forth between your reading and coding so that your book knowledge and its practical application are mutually reinforcing. This way, you’ll not just know a concept, but you’ll also understand the concepts.

Focus most on the topics you’re least comfortable with. Grade yourself on each of the topics in OCPJP 8 exam on an ascending scale from 1 to 10. Do remedial preparation in all the topics for which you rate yourself 8 or less.

FAQ #9. Can I pass OCJP if I have done only dumps?

Dumps might help you to get through the exam. But, what is more important is the knowledge and confidence you gain while preparing for the exam (while keeping your conscience clear).

Consider this example. With help of dumps Mr.X has cleared the exam and got certified. He proudly added his certification in his resume and got shortlisted for an interview. In the interview he was asked questions that were covered in the exam topic as the interviewer noticed that he is a Java Certified Professional. But Mr.X was unable to answer the questions because he did not understand the topics well though he cleared the certification.

So, it is more important to prepare for the exam and understand the concepts well. Do take a number of mock exams to self-evaluate how prepared you are for taking the exam.

FAQ #10. What books should I read for cracking Java Oracle certification?

OCJP 8 is the latest version in Java oracle certifications and the exam has considerable focus on the newly added features; so reading books related to Java 8 will help you in cracking the exam.

FAQ #11. I know some of the Java 7 and Java 8 features, but how much depth should I go to crack the OCPJP 8 exam? What are the unique features of your OCP 8 book?

In-depth and 100% coverage of all 12 exam topics for the certification – in other words, all exam topics covered in necessary depth and breadth (no more no less than that is required).

Numerous illustrative programming and real-world examples – we have tried our best to make most of the programs self-contained; source code is available for free download here.

A full-length mock exam plus numerous practice questions at the end of each chapter – that’s 200+ sample questions!

Frequently Asked Questions (FAQ) chapter provides a clear overview of the exam and the preparation process.

There are also other features such as exam tips, warnings, and notes. There is also good online supporting material in our website, such as the exam quick reference card. With all this, I am sure that your effort for preparing for OCP 8 exam becomes less and it becomes easier to crack this difficult exam.

FAQ #12. So what can we expect in the exam, are the questions strictly based on the objectives?

In our experience, exam questions weren’t strictly based on objectives – there were some questions which we thought were not mentioned at all in the objectives. But relatively they were few in number. We could match each question with one or more exam topics. So, it is critical to focus on exam objectives for cracking the exam.

FAQ #13. How much harder is OCPJP 8 than OCPJP 7? Is your book focused on OCPJP 8 exam or on the upgrade exam?

We have both OCPJP 7 as well as OCPJP 8 certifications; so for us, both were of same difficulty level.

Our book is focused more on OCPJP 8 exam (specifically, 1Z0-809 exam). When designing the book, we carefully thought about supporting 1Z0-810 and 1Z0-813 (“Upgrade to Java SE 8 OCP” and “Java SE 6 and all prior versions”). Though the book covers all the topics, if we mention these exams in the title, then we thought we should ideally have practice exams for these certification paths. That will require three mock exams, i.e., for 1Z0-809, 1Z0-810 and 1Z0-813 exams. For this reason, we did not mention that our book supports all these three exams. However, the book is good for preparing for all these three exams (assuming that you can get mock tests from other sources for the upgrade exam).

FAQ #14. How much should I prepare, considering that I’ve scored 90 for OCPJP 7? Can I skip any chapters in the book to be ready sooner?

Wow, 90% is an amazing score!

Unlike moving from Java 5/6 to Java 7 which was mostly easy for us and relatively effortless, transition from Java 7 to Java 8 was much more difficult for us. Though we had exposure to functional programming constructs because of programming in Groovy, still there was a steep learning curve for us to understand lambdas as supported in Java 8, functional interfaces and stream API. Date and Time API is fun and amazing, but it was also completely new to us (we have not used Joda API in the past). So, we underestimated the effort required to learn Java 8 language and library additions and the book revision also took much more time. To cut the long story short: Please don’t underestimate the time or effort required to learn Java 8 language and library features.

That said, since you already have OCPJP 7 certification, you can straightaway skip half of the chapters covered in our book, including class design, JDBC, localization, Java I/O and Java NIO.2, and exceptions and assertions. For other chapters like Generics and Collections, because of lambdas and streams, there are considerable changes in the exam topics. So, you still need to prepare for these topics.

FAQ #15. How many lambda related questions are in the new exam? Is your book focused on lambda or it’s a solid book for any OCA 7- programmer?

There were quite a few lambda related questions in the new exam. Also, there were numerous questions on stream and date/time API. The book is not focused on lambdas – it is a book focused on OCPJP 8 exam. And, it is a solid book for those who have already cleared the OCAJP 8 exam (which is a prerequisite for the OCPJP 8) exam.

We really like the Java 8 features and we have become a big fan of Java streams (especially parallel streams) and the date/time API. So, getting certified or not, we recommend you to get updated with Java 8, and we are sure that you won’t regret for that!

FAQ #16. Which do you think is preferable (in exam perspective): a book that is specifically based on the certification objectives or a book which discusses all the possible topics under a certain objective?

Ideally, a book should cover all the topics under certain objectives. However, there is a practical problem from exam preparation perspective: there are too many topics to cover! Take concurrency for example – if we cover all the topics, one can easily write book(s) – in fact, there are many books focusing on Java concurrency alone.

So, from practical exam-taking perspective, it is better to limit the content and preparation to exam topics explicitly mentioned in the Oracle exam topics.

FAQ #17. I have Java SE 1.4 certification and I want to get Java SE 8 certification. Which exam should I take?

Please check this comparison table that compares OCA and OCP SE 8 exams. Since you have SCJP (for Java 1.4), you can choose to take either 1Z0-809 or 1Z0-813 exam.

Java language (e.g., lambdas and functional interfaces) and library (e.g., streams and date/time API) have evolved a lot from 1.4. So, we would suggest you have getting the OCP 8 certification as the objective for learning the recent updates in language and library in Java.

FAQ #18. How do I register for the exam, schedule a day and time for taking the exam, and appear for the exam?

Option 1: Register and pay on the Pearson VUE website using the following steps:

Step 1. Go to http://www.pearsonvue.com/oracle/ (you will be directed here if you click the first option from Oracle Certification page). Click on “Schedule online” in “Schedule an exam” section.

Step 2. Select “Sign In.” Click on “proctored” in the “what type of exam you are planning to take” section. Select this exam as “Information Technology (IT)” ➤ “Oracle” ➤ “Proctored” . Then you’ll be asked to sign in.

Step 3. Log in to your web account on the Pearson site. If you don’t have one, create one; you will get the user name and password by the e-mail you provide. When you log in first time, you need to change your password and set security questions and their answers. When you are done with this, you’re ready to schedule your exam.

Step 4. Once logged in, you’ll get the list of Oracle exams to select from. Select the following exam:

1Z0-809, Java SE 8Programmer II(aka OCPJP 8 exam)

These exams are in English (You can choose another language if you wish and if it is available in the list). This page will also show you the cost of the exam. Click Next.

Step 5. Now you need to select your test location. Choose Country ➤ City ➤ State/Province, and you’ll be shown test locations close to you. Each centre will have an icon for information: click it for the address and directions. Select up to four centres near your location and click Next.

Step 6. Select a test centre and select a date and time for appointments. The page will indicate the available dates and time slots; choose the one most convenient for you. If you have an exam voucher or Oracle University coupon or Oracle promotion code, enter it here.

Step 7. Select from the available payment options (the usual way is to pay using your credit card) and pay your exam fees. Make sure that you have selected the right exam, appropriate test centre, and date/time before paying the fees.

Step 8. Done! You will get an appointment confirmation payment receipt by e-mail.

Option 2: Buy an exam voucher from Oracle and register on the Pearson VUE website.

You can buy a generic exam voucher from Oracle and use it at the Pearson site. It costs US$245 if you are living in the United States and is denominated in an appropriate currency if you live elsewhere. To buy the voucher from Oracle, select “OU Java, Solaris, and other Sun Technology Exam eVoucher.” You will be asked to create an Oracle account if you do not have one. Once the account is created, confirm customer type, customer contact information, and pay. Once you pay the fees, you can use the eVoucher at the Pearson VUE site.

Option 3: Register and pay online to take the exam in person at an Oracle Testing Center (OTC).

You can choose this option if a physical exam session is scheduled in your vicinity. It costs US$245 or the local equivalent.

FAQ #19. What are the key things I need to remember before taking the exam and on the day of exam?

Before the exam day:

You’ll get e-mail from Pearson confirming your appointment and payment. Check the details on what you should bring when you go to the exam center. Note that you’ll need at least two photo IDs.

Before the exam, you’ll get a call from the Pearson exam center where you’ve booked your appointment.

On the exam day:

Go to the exam center at least 30 minutes before the exam starts. Your exam center will have lockers for storing your belongings.

Show your exam schedule information and IDs and then complete the exam formalities, such as signing the documents.

You’ll be taken to a computer in the exam room and will log into the exam-taking software.

Taking the exam:

You will see the following on the exam-taking software screen:

A timer ticking in one corner showing the time left

The current question number you are attempting

A check box to select if you want to review the question later

The button (labeled “Review”) for going to a review screen where you can revisit the questions before completing the exam.

Once you start, you’ll get questions displayed one by one. You can choose the answers by selecting them in the check box. If you are unsure of an answer, select the Mark button so that you can revisit it at any point during the exam. You can also right-click on an option to strike-through that option (useful for eliminating incorrect options).

You may not consult any person or print or electronic materials or programs during the exam.

After the exam:

Once you’re done with the exam, you will not be immediately shown the results.

Irrespective of passing or failing the exam, topics from questions you’ve answered incorrectly will be supplied with your score.

If you’ve passed the OCPJP 8 exam and you’ve also satisfied the applicable prerequisites for certification (e.g., OCAJP 8 certification as the prerequisite of OCPJP 8 certification via the 1Z0-809 exam), a printable certificate will be e-mailed to you.

If you failed the exam, you may register and pay again to retake it after a 14-day waiting period.

FAQ 20. Do you have any URL which gives more information about OCPJP certification?

Deque (Doubly ended queue) is a data structure that allows you to insert and remove elements from both the ends. The Deque interface was introduced in Java 6 in java.util.collection package. The Deque interface extends the Queue interface. Hence, all methods provided by Queue are also available in the Deque interface.

There are three concrete implementations of the Deque interface: LinkedList, ArrayDeque, and LinkedBlockingDeque .

The problem is that next() was not called before calling remove() . Checking hasNext() in the while loop condition, moving to the element using next() , and calling remove()is the correct idiom for removing an element. If you don’t follow it correctly, you can get into trouble (i.e., you’ll get IllegalStateException ).

One of the major new language features in Java 8 is lambda function. In fact, it is one of the biggest changes since Java 1 release. Lambdas are widely used in the programming language world including the languages that compile to the Java platform. For instance, Groovy language compiles to the Java platform and has a very good support for lambda functions (also known as closures). Oracle decided to bring lambdas to the mainstream language on the JVM-the Java language itself-with Java 8.

LAMBDA FUNCTION RELATED CHANGES IN JAVA 8

Introduction of lambdas required coordinated changes in the language, library, and the VM implementation:

The arrow operator (“->”) for defining lambda functions, the double colon operator (“::”) used for method references, and the default keyword

The streams library and the integration of the collections library with streams

Lambda functions are implemented using the invokedynamic instruction introduced in Java 7

To support introduction of lambdas into the language, the type inference has also been strengthened in Java 8. Lambdas enabled library writers to create parallel algorithms in the library to exploit inherent parallelism in the modern hardware (i.e., multi cores).

In Java 8, java.util has been considerably enhanced using lambda functions. Java 8 has added two new packages java.util.function and java.util.streams.

Lambdas can significantly change the way you design and write code. Why? Lambdas support functional programming paradigm – that means learning and using lambdas would mean a paradigm shift to you. But you don’t need to worry about making a major shift—Java seamlessly integrates functional capabilities with the existing object oriented features and you can gradually shift to using more and more functional features in your programs.

Lambda Functions: Syntax

A lambda function consists s of optional parameters, the arrow token, and the body:

LambdaParameters -> LambdaBody

LambdaParameters are parameters to the lambda function are passed within opening parenthesis “(” and closing parenthesis “)”. When more than one parameter is passed, they are separated by commas.

The arrow operator. To support lambdas, Java has introduced a new operator “->”, also known as lambda operator or arrow operator. This arrow operator is required because we need to syntactically separate the parameter from the body.

LambdaBody can be an expression or a block. The body could consist of single statement (in that case no explicit curly braces defining a block are required); such a lambda body is known as “expression lambda.” If there are many statements in a lambda body, they need to be in a block of code; such a lambda body is known as “block lambda.”

Compiler performs type inference for lambda expressions:

The compiler infers the type of the parameters if you do not specify the type parameters in a lambda function definition. When you specify the type of parameters, you need to specify all or none; or else you will get a compiler error.

You can omit the parenthesis if there is only one parameter. But in this case, you cannot provide the type explicitly. You should leave it to the compiler to infer the type of that single parameter.

The return type of the lambda function is inferred from the body. If any of the code in the lambda returns a value, then all the paths should return a value; or else you will get a compiler error.

Some examples of valid lambda expressions (assuming that relevant functional interfaces are available):

(int x) -> x + x

x -> x % x

() -> 7

(int arg1, int arg2) -> (arg1 + arg2) / (arg1 – arg2)

Examples of invalid lambda expressions:

-> 7

// if no parameters, then empty parenthesis () must be provided

(arg1, int arg2) -> arg1 / arg2

// if argument types are provided, then it should be provided

// for all the arguments, or none of them

Lambda Function—An Example

Let us get started with a simple “hello world” example for lambda functions

In this program, the interface LambdaFunction declares an abstract method named call() ; hence it is a functional interface. Inside the main method in FirstLambda class, a lambda function is assigned to a variable of the functional interface type LambdaFunction.

The statement System.out.println(“Hello world”) is the body of the lambda expression.

How does the lambda expression relate to the functional interface LambdaFunction? It is through the single abstract method inside the LambdaFunction interface: void call(). The signature of this abstract method and the lambda expression must match:

The lambda expression has () indicating it has no parameters—it matches with the call method that takes no parameters.

The statement System.out.println(“Hello world”) is the body of the lambda expression. This body serves as an implementation of the lambda function.

There is no return statement in this lambda expression body and hence the compiler infers the return type of this expression as void type—that matches with the return type of the call method.

The next statement lambdaFunction.call(); invokes the lambda function. As a result of this function call, “Hello world” is printed on the console. Check out this bookfor more learning about Lambda Functions. You can download the source code here.