Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.

Paul Anilprem

Enthuware Software Support
+ Follow
since Sep 23, 2000
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Anilprem

Stephan van Hulst wrote:
Volatile establishes a happens-before relationship between executions of statements the same way synchronized does (referring to reordering of statements and writing and reading from main memory), but its main drawback is that it can't make execution of multiple operations atomic.

I wouldn't call it a drawback. There are situations (such as the ones you mentioned) where synchronization is not required. Why would you pay the extra cost incurred by synchronized when all you need is to ensure that updates made by one thread are visible to another?

That's why the volatile keyword is almost completely useless.
The only common use case I've found for it is when the variable represents a very simple flag to cancel an operation that's in progress, or to flag that an operation has started or finished.

This use case is actually quite common Hence, not almost completely useless.

Stephan van Hulst wrote:

Paul Anilprem wrote:volatile is kind of a cheaper alternative to synchronization

The volatile is not an alternative, because it can't do everything that synchronized does.

Two things  - 1. the sentence before the one that you have quoted, says the same thing. synchronize does something in addition to what volatile does. So, when you need just the stuff that is common to both (i.e. visibility), volatile is indeed an alternative and is cheaper.
2. The usage of the phrase "kind of" kind of implies that I don't mean to say that synchronized and volatile are exactly the same

But if you just want to focus on the word "alternative" out of context, then yes, you are right. It is not an alternative.

Zhenyang Hua wrote:On Page 688/689, the book says the race condition could be fixed making getInstance() method synchronized AND the INSTANCE variable volatile:

Then it gives the explanation that the volatile makes sure the check null and create new Show() two steps are considered atomically one step (as they have the same visibility in the main memory by marking them volatile my guess), but is it really needed to use volatile since the getInstance() method is marked synchronized already? Wouldn't the synchronizing block other threads while it is executing so it is already considered thread-safe?

No, volatile is not needed in this case. Java memory model ensures that if a variable (irrespective of whether it is declared volatile or not) is accessed only from synchronized blocks (synchronizing on the same lock), then the value written by one thread will be visible to another thread that is trying to read that value.
synchonization and volatile both ensure visibility but synchronization ensures ordering in addition to visibility. volatile is kind of a cheaper alternative to synchronization

This is not a topic that can be explained with all its nuances in a forum post. Since it is an important topic, you may want to go through a good book to understand this. This article also explains it nicely for a start.
These are frequently asked questions relating to the Oracle Certified Associate, Java SE 5/6, Java SE 7, and Java SE 8 Associate (OCA) certifications, and the common answers to them.

Where can I ask questions about the OCAJP exam that aren't covered in this FAQ?
That's what the CodeRanch Associate Certification (OCAJP) discussion forum is for.

Where can I find the OCAJP exam objectives?
Objectives are the goals for the exam to prepare you on certain topics. You can think of objectives as Syllabus of the exam.
  • OCAJP 8 (1Z0-808) objectives
  • OCAJP 7 (1Z0-803) objectives

  • How do the OCAJP objectives map to the old SCJP/OCPJP 6 exam?
    See the mapping table at OCAJP7 and OCPJP7 vs OCPJP6

    How do the OCAJP 8 objectives map to version 7?
    See the mapping table at OCAJP7 vs OCAJP8

    Who is the target audience for the OCAJP 5/6 exam versus the OCAJP 7/8 exam?
    From the SCJA Study Guide ... in regards to the SCJA which is now the OCAJP 5/6 (1Z0-850) exam:

    SCJA Study Guide wrote:We strongly recommend the SCJA certification to the following candidates:
    * Entry-level and junior programmers wishing to start and/or continue down the path of using Java technologies.
    * Software developers and technical leads wishing to solidify their Java-related skillsets.
    * Project and program managers wishing to gain a true perspective of the work and challenge of their teams complementary to their planning and direction.
    * Computer Science and information system students wishing to complement their education
    * IT job seekers looking for a well-deserved edge
    * Certification seekers wishing to round out their resume or curriculum vitae

    In regards to the OCAJP 7 (1Z0-803) exam, it's primarily good for matured programmers & software developers.

    What is the difference between the OCAJP 5/6 and OCAJP 7?
    I'm confused, is there an updated SCJA exam given by Oracle?

    Are there any books / resources for this certification?

    OCAJP 8 Books - OCA Java SE 8 Programmer I (Exam 1Z0-808)
  • OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 (Wiley), Errata
  • OCA Java SE 8 Programmer I Study Guide (Exam 1Z0-808) (Oracle Press) (McGraw-Hill Education)
  • A Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) (Addison-Wesley Professional), Errata
  • OCA Java SE 8 Programmer I Certification Guide (Exam 1Z0-808) (Manning Publications)
  • OCAJP Associate Java 8 Programmer Certification Fundamentals (Exam 1Z0-808) (Enthuware)

  • OCAJP 8 Video Courses - OCA Java SE 8 Programmer I (Exam 1Z0-808)
  • Oracle Certified Associate, Java SE 8 Programmer I (1Z0-808) Complete Video Course

  • OCAJP 8 Free Training & eBook - The Java Certification Roadmap
  • Java Programmer Certification Free Training
  • The Java Certification Roadmap eBook

  • OCAJP 7 Books - OCA Java SE 7 Programmer I (Exam 1Z0-803)
  • OCA Java SE 7 Programmer I Study Guide (Exam 1Z0-803) (Oracle Press) (McGraw-Hill Education)
  • OCA Java SE 7 Programmer I Certification Guide: Prepare for the 1ZO-803 exam (Manning)
  • OCA/OCP Java SE 7 Programmer I & II Study Guide (Exams 1Z0-803 & 1Z0-804) (Oracle Press) (McGraw-Hill Education), Errata
  • OCAJP Oracle Certified Associate Java SE 7 Programmer Practice Exams (Enthuware)

  • OCAJP 7 Video Courses - OCA Java SE 7 Programmer I (Exam 1Z0-803)
  • Oracle Certified Associate, Java SE 7 Programmer Exam (1Z0-803) Complete Video Course

  • Are there any summaries (made by CodeRanch members) for this certification?
  • How to get java certification: step by step by Mushfiq Mammadov
  • OCAJP 7 Summary by Mohammed Amine Bagdouri
  • Java OCAJP 8 Certification by Paul Robotham

  • Has anyone blogged about the exam?
  • Robert James Liguori's Blog, Getting Certified with Java SE 8

  • What are the free mock exams available?
  • Oracle posted sample questions
  • Whizlabs' OCAJP 7 Free Test and OCAJP 8 Free Test
  • Enthuware's JA+ V7 For OCA-JP Trial Version and JA+ V8 For OCA-JP Trial Version
  • JavaBeat's Java Basics mock exam
  • 20 questions OCA 8 questions/answers in free book preview of Wiley's OCA 8 book
  • MyExamCloud's Free 1Z0-803 Java SE 7 Programmer I Practice Mock Exam and Free 1Z0-808 Java SE 8 Programmer I Practice Mock Exam
  • 10 questions for StringBuilder Topic
  • 9 questions for Lambda Topic
  • 11 free questions on enums
  • Types of questions you'll see on the Java exam (includes 8 free sample questions)
  • 15 free questions on String pool

  • What are the commercial mock exams available?
  • Whizlabs' OCAJP 7 Practice Tests and OCAJP 8 Practice Tests
  • Enthuware's JA+ V7 For OCA-JP Full Version and JA+ V8 For OCA-JP Full Version
  • JavaBeat's OCAJP 7/8 Mock Exams with 400 sample certification questions
  • MyExamCloud's OCAJP 7 (1Z0-803) Exam Practice Tests and OCAJP 8 (1Z0-808) Exam Practice Tests

  • Are there any tips and advice for taking this exam?
    In the OcajpWallOfFame you'll find experiences (including resources they have used) about other ranchers having already passed the OCA exam. So these experiences and stories could also be very useful.

    What is the policy on posting questions I saw on the exam?
    You may not describe or talk about the questions you saw on any of the Oracle exams - see the CodeRanch's Policy on Real Questions for further details.

    What other certifications do I need before I go for the OCAJP certification?
    No prerequisites for this certification.

    Where can I find the FAQs for the legacy SCJA exam?
    The SCJA FAQs can be found here.

    Where do I see my certification results?
    See our certview wiki page

    CategoryFaq CategoryCertification
    4 days ago
    More important than your low scores on the mock exams is the fact that your scores are not increasing. One should ideally get into the 70s by the third/fourth test if they get a 60 in the first/second test. Your first score of 57% indicates that you were weak on several fundamental concepts and going through a good book before taking the next test might have been better.

    I would suggest you to reschedule the test to at least a couple of weeks later. In this time, try to go through a book. If you have already gone through one, try a different one. (You can get a free copy of this book from here.) and then take the remaining mock tests. Your score should increase and you will feel more confident about the real exam.
    This code is from question id enthuware.ocajp.i.v8.2.1494. The correct option is "In" and that itself tells you the method that will be invoked. I see that an explanation is also given with option 3.

    It will not compile if you make this change because it is illegal to invoke a static method of an interface using a reference variable. If you want to invoke a static method of an interface, you need to use the name of the interface. For example,;  You can use a reference variable to invoke a static method of a class or super class though. So this is valid: ((Wow)f).wow(); even though it is not a good practice to use a reference to invoke a static method.

    More explanation is now being added to make it clearer.

    Congratulations, Sean! Great score!!
    You score has decreased from From Test 2 to Test 5. That is worrying. Unless there is some reason that is unrelated to your preparation, the score progression shows that you have not learned enough from your mistakes in the previous test before attempting the next one.
    I would suggest you to go through the explanation for each question that you missed and, if required, read up on those topics from a book. Then take Test 6 and see if you score increases. Repeat the same process for the rest of the tests.

    If you are not able to score more than 65% in the remaining three tests, I would suggest you to postpone the exam.

    Congratulations, Bruno! Great score!!
    2 weeks ago
    This happens when your card does not have international payments enabled. You will need to talk to your bank to enable international transactions.
    As Ganesh suggested, it would be better to contact us through email with your name and emailid so that the exact cause of failure can be traced.
    Congratulations, Arpan!
    Glad to know that our material was helpful in your preparation.
    thank you for posting the details of your journey.
    1 month ago
    Congratulations to the winners and thanks to JavaRanch for doing the promotion!

    If you haven't won, but would like to have a copy anyway, please add your emailid to the list here:
    Congratulations, Adrian!
    1 month ago