This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

Jeanne Boyarsky

author & internet detective
+ Follow
since May 26, 2003
Jeanne likes ...
Eclipse IDE Java VI Editor
Forum Moderator
New York
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 Green check
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt Green check

Recent posts by Jeanne Boyarsky

CodeRanch Book Promotions - This Year's Winners

A big Congratulations to all our winners!

See our BookPromotions2019Winners

January 7Cloud Native DevOps with Kubernetes: Building, Deploying, and Scaling Modern Applications in the Cloud John Arundel & Justin Domingus  O'ReillyTim Holloway, Greg Horie, paul nisset, Rashmi varmaSent in winners (2/5/20)
January 14Cloud Native TransformationPini Reznik, Jamie Dobson & Michelle Gienow  O'ReillyGreg Horie, Justin Domingus, Tim Holloway, Ian MiellSent in winners (2/5/20)
January 14The Go WorkshopDániel Szabó, Andrew Hayes, Et alPacktWill Myers, Campbell Ritchie, Carl ByrdSent in winners (2/5/20)
January 21Programming with TypesVlad RiscutiaManningpaul nisset, Jose Samonte, Ron McLeod, David Sachdev Sent in winners (2/5/20)  *Ron McLeod received redemption code (2/6/20)*
January 21The Design of Web APIsArnaud Lauret  ManningTodor Kolev, Yury Nebieridze, Jose Samonte, meenakshi sundarSent in winners (2/5/20)
January 28Kotlin CookbookKen KousenO'ReillyRandy Tong, satya Priya Sundar , Lanny Gilbert , Will MyersSent in winners (2/5/20)
February 4Docker in ActionJeff Nickoloff & Stephen Kuenzli  ManningRon McLeod, paul nisset, Will Myers, Tim HollowayWaiting for winners info
February 11Secure By Design Daniel Deogun, Dan Bergh Johnsson & Daniel SawanoManningWaiting for winner info

Note: All dates in mm/dd/yyyy format

Go back to the main BookPromotions page.

For questions about this page or to schedule a promotion, contact: bookpromotion AT javaranch DOT com
3 days ago
Scheduled promotions:

Note: We can run more than one promo in a given week, so check for updates.

Starting DateCoverBookAuthor(s)PublisherCodeRanch Forum
February 18  GANs in ActionJakub Langr & Vladimir Bok  ManningAI
February 18WebAssembly in ActionGerard Gallant ManningJavaScript
February 25Machine Learning for Business: Using Amazon SageMaker and Jupyter Doug Hudgeon  & Richard Nichol  Manning Python
February 25  Object Design Style Guide Matthias Noback  ManningOOP
March 3Practices of the Python ProDane Hillard  Manning Python
March 3  Deep Learning with JavaScript: Neural networks in TensorFlow.js  Shanqing Cai, Stan Bileschi & Eric NielsenManningAI
March 10 Seriously Good Software Marco Faella  Manning Refactoring
March 17TypeScript QuicklyYakov Fain (Author), Anton Moiseev  ManningJavaScript
March 17[ur=]Mastering Large Datasets with Python[/url]   J. T. Wolohan  Manning Python
March 24Hello WorldWarren & Carter Sande  ManningPython
March 31Available
April 7Available
April 14Available
April 21Available
April 28Available

Go back to the main BookPromotions page.
3 days ago
First, a big thanks to Daniel Deogun, Dan Bergh Johnsson & Daniel Sawano for being here to promote the book Secure by Design.

The winners are:

Campbell Ritchie
paul nisset
Vidya Nara
Jon Pelipas

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Country (needed even if requesting an e-book)
Phone Number

Also, please include the following as the subject of your Email.

Book Promo Winner - Secure by Design - Tuesday, February 11th, 2020

Image from

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.
3 days ago
Also, Manning is a Buy One Get One Free sale at the moment. Nice!
1 week ago
This week, we're delighted to have Daniel Deogun, Dan Bergh Johnsson & Daniel Sawano helping to answer questions about the new book Secure by Design.
See the table of contents online.

The promotion starts Tuesday, February 11th, 2020 and will end on Friday, February 14th, 2020

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, Manning.

Image from

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.
1 week ago
Please use the Programmer Certification (SCJP/OCPJP) forum to post your own question. See SCJP-FAQ for Java 6 and earlier specific content and OCP 11 FAQ for Java 11 content

Note that Java 7 exam has been retired

OCPJP FAQ Contents

Questions about Oracle Resources

  • Where can I find the official OCPJP FAQ from Oracle?
  • What are the OCPJP objectives?
  • Where can I find the Java Language Specification?
  • Where can I find the Java API documentation?

  • General Questions about the Exams

  • How is the OCPJP 8 different from the OCPJP 7?
  • How is the OCAJP 7 and OCPJP 7 exam different from the SCJP/OCJP 1.6?
  • What are the upgrade exams?
  • If my last SCJP was 1.4 can I take the 7 upgrade or do I have to take the full 17 exam?
  • Is the upgrade exam easier than the full exam?
  • Can I bring something to write on?
  • How important are the scores?
  • If I fail, can I take the exam again?
  • How long will my certification last before expiring?
  • Where can I find information about certification outside of the U.S.?
  • What is the pattern of the expiration date on the exam voucher?
  • Will I be told how many options to choose in a multiple choice question?
  • Are there any marks for partially right answers?

  • Questions about Exam Preparation (Books, Notes, Mock Exams, etc.)

  • What is the best way to prepare for the OCPJP exam?
  • What books should I refer to when studying for the OCPJP?
  • Where can I find preparation notes?
  • Are there supporting courses for preparing the exam?
  • What are some mock exams available? see ScjpMockTests
  • How does the user-interface of the real exam look like? Check ExamLab
  • Are there any mock exams that allow Exam Objectives section-wise tests?
  • Am I ready to take the exam?
  • What resources should I study to meet the Objectives for SCJP 310-025 exam?

  • Questions on Specific Topics

  • What are some potential trips/traps in the SCJP exam?
  • What are the Java standard keywords? Are true, false, and null keywords?
  • What does strictfp mean?
  • Can I have more than one class in a .java source file?
  • Is it allowed to declare the main method private?
  • Can static methods be overridden?
  • Are string literals eligible for GC?
  • char a = '\u000A'. Why is this invalid?
  • How can you compare NaN values?
  • How does InterruptedException affect a thread?
  • What are the important I/O constructors and methods?
  • What is the difference between getAbsolutePath() and getCanonicalPath()?
  • Could someone explain the Regex2 class from K&B's Java 5 Study Guide?
  • How many String objects are there? What is the String pool?
  • Why do separate autoboxing conversions sometimes return the same reference?
  • What is a most-specific method?
  • Why are the notify, notifyAll and wait methods defined in the Object class instead of the Thread class?
  • What's up with integers not being equal to one another?

  • Where can I find the official OCPJP FAQ from Oracle?

    What are the OCPJP objectives?

    Objectives are the goals for the exam to prepare you on certain topics. You can think of objectives as Syllabus of the exam.
  • OCPJP (Java SE 7 programmer II or 1Z0-804) Exam Topics
  • OCPJP (Java SE 8 programmer II or 1Z0-809) Exam Topics

  • What are the upgrade exams?

    The upgrade exams are for candidates who already hold an SCJP certification under a prior version and want to be certified under a more recent version. For example, if you have already passed the SCJP 1.4 exam and want to upgrade your certification to version 7, then you can take the OCPJP 7 Upgrade exam.

    For more information see:

  • OCPJP 7 Upgrade (1Z0-805)
  • OCPJP 8 Upgrade from Java 6 or earlier (1Z0-813)
  • OCPJP 8 Upgrade from Java 7 (1Z0-810)

  • Also see [Java8UpgradeExams]

    If my last OCPJP was 1.4 can I take the upgrade or do I have to take the full exam?

    No. You can just take the upgrade exam. As long as you have OCPJP in any previous version you can take a OCPJP upgrade. Make sure to take the right exam for what version you are upgrading from.

    Is the upgrade exam easier than the full exam?

    Well there are less questions but the pass mark is slightly higher. The upgrade has 80 questions, a 60% pass mark and allows 150 minutes.  The full exam has 90 questions, a 64% pass mark and still allows 150 minutes.  However, the upgrade exam focuses on the new content.

    What is the best way to prepare for the OCPJP exam?

  • Familiarize yourself with Sun's exam process, including objectives, registration, testing, etc. See Sun's SCJP page for details.
  • If you are new to Java programming, start with a good introductory book such as Head First Java or Thinking in Java. Check the JavaRanch Bunkhouse for additional recommendations and reviews. Refer to the API documentation and the Java Language Specifications along the way. (See links in this FAQ.)
  • Once you have a foundation, study at least one good (and current) certification preparation book. (See recommendations in this FAQ.)
  • Use the OCPJP forum to post questions, and reinforce your own understanding by answering other people's questions.
  • Take as many mock exams as possible. (See links in this FAQ.) Use these to determine where additional study is needed, and as a guide to when you are ready.

  • Contributed by Mike Van...

    In my dark and horrid past, I ran an organization that prepared newcomers for the Java Cert exam. As such, I have some insight you may find useful.

  • Go through one book at a time, don't skip around between books because it will confuse you. Specifically with regard to the certification objectives, areas like Threads may be taught differently in different books. As such, its best to have one teacher at-a-time instead of numerous. Learning it multiple ways AT THE SAME TIME, will lead to confusion.
  • If you're brand-spanking new to Java, don't go directly to a Java Cert book. These books were not created for beginners, they were created for people who understand the basics of Java programming. Instead, spend a month or so getting to know the language with a "Learning Java" type book. If you are new to programming altogether, you may want to precede the learning java type book with a basic computer programming book.
  • Code Code Code. There is a lesson to be learned in every code example of every book you read. Learn the lessons and learn to code at the same time. The difference between someone who has spent the time to code and someone who is merely memorizing answers is immediately apparent in thier test progress. Someone who codes regularly will quickly pick-up on the intricate questions being asked on the exam. Someone who is memorizing answers will get lost easily once the questions deviate from what they've memorized. On the job, the memorized-no-coding person will be quickly fired, while also proving the test to be inneffective in the minds of the employer who f/hired them.
  • Study with friends. There's an old axiom that goes: "if you put 100 programmers in a room and give them 1 problem, you'll get 100 different answers, and most will work." By studying with others you'll be able to see how others approach the questions and exercises you'll be studying. When I study for a certification, my initial approach to a problem is rarely the best one. But if I'm studying with others, I can see many approaches and find out which one is best for me.
  • Use Mnemonic Devices. The thing about memorable mnemonics is that they help put information into your long-term memory instead of your near-short term memory. This means you won't be "brain-dumping" your newly learned lessons after the test. My favorite mnemonics are acronyms. Its amazing how memorable a lasciviously written acronym is. :-) Make 'em dirty to make 'em last.
  • Don't try to learn the entire language in a week/month, take your time. There's the French cognitive psychologist name Piaget who postulated that adults learn sequentially and cumulatively. Basically what this means is that before you can learn how to write an inner class, you first need to learn how to write a regular class. You can try and skip right to the inner class if you want, but you won't learn the "whys" of it. Its just as important for us human beings to learn the background of something as it is to learn the thing itself. Now, if you're a martian, venusian, or uranusian, that may not apply. if you are a venusian learning Java, I say welcome to our new Venusian Overlords!
  • Learn "why" something works a given way, not just that it works one way. Other psychologists have postulated that there are three stages to learning. There's recognizing something, rote memorization, and being able to create something new from your memorized material. This is usually applied to the learning of human languages, but it applied to Java Certification prep as well. Here's how they differ. Being able to recognize that something is written in Java is nice, but you have to know how to use the language also. Recognizing but not really being able to use is the first level. Not really useful. Being able to recite all parts of the Java Language is certainly better than just recognizing it. Unfortunately, being able to recite the number of bits in an Integer doesn't mean you'll be able to use it in code. Finally, being able to create algorithms in the language, that's where you want to be before you take your certification exam. That's what employers are looking for. That's why K&M ask you questions that make you think. And that's why the people that can use the language most effectively are the ones who don't get laid off.

  • Contributed by Rahul Bhattacharjee, SCJP1.4...

    Apart from the programming questions one should also concentrate on the theory (encapsulation...) also. As the basic theory questions would also have the same weightage.

    Check this link for the features new to JDK 1.5.

    What books should I refer to when studying for the OCPJP?
    SCJP Sun Certified Programmer for Java 6 Study Guide by Katherine Sierra and Bert Bates (K&B) is One of the most popular (and recommended) book for SCJP -- ISBN 0071591060. The Java 5 Study Guide is also available -- ISBN 0072253606. - plus read the Java 7 topics on Oracle's website.  The updated book for Java 7 comes out in 2014.
    OCP Java SE 7 Programmer II Certification Guide - prints in 2014
    "Oracle Certified Professional Java SE 7 Programmer Exams" by Ganesh and Sharma -- ISBN 1430247649
    OCP 8 Study Guide by Boyarsky & Selikoff
    OCA/OCP 8 Practice Questions by Selikoff and Boyarsky

    Check the JavaRanch Bunkhouse for additional recommendations and reviews.

    Where can I find the Java Language Specification?

  • Java 7 edition:

  • Where can I find the Java API documentation?

  • Java 7

  • What are some mock exams available?

  • see ScjpMockTests

  • Where can I find preparation notes?

    OCPJP 7:
  • Mikalai Zaikin's OCPJP 7 Upgrade Notes

  • OCPJP 8:
  • OCP Java (OCPJP) 8 Exam Quick Reference Card (Hari Kiran & Ganesh S.G.)

  • Various Versions:

  • Enthuware Resources
  • Dylan Walsh's Pre-Exam Essentials

  • Are there supporting courses for preparing the exam?

  • Whizlabs SCJP 6 Online Instructor led Training
  • Sun Training

  • Are there any mock exams that allow Exam Objectives section-wise tests?

  • CertPal
  • Exam EPractize Labs
  • Dan Chisholm's Test Suite
  • Marcus Green's Site
  • JavaBeat Certification Kit
  • JCertify
  • uCertify Java PrepKits
  • Nikos Blog
  • Whizlabs SCJP 6 Exam Simulator, OCPJP 7 Exam simulator, OCPJP 7 Upgrade Exam Simulator, Java Certification Kits

  • Can I bring something to write on?

    You cannot bring anything with you into the testing room. You will be provided with something to write on and something to write with. This varies by testing center, but often it is a small erasable white board and a marker. You cannot take anything with you from the testing room when you leave.

    If you have any doubts or concerns about this policy, please verify with your testing center before appearing for the exam.

    How important are the scores?

    Scores are not displayed on certificates (passing is passing), but scores can look impressive on resumes.

    If I fail, can I take the exam again?

    Yes, but you will need to purchase another voucher and wait 1 week before retesting. See Sun's FAQs for more details.

    How long will my certification last before expiring?

  • "If a Sun certified professional has already received a certificate and ID card with the printed expiration date, can that professional request another certificate and ID card without an expiration date? Yes. The certified professional will need to send an email to the alias to request a new certificate and ID card. Include your name and Prometric Candidate ID number."

  • "Beginning with all Sun certification exams taken on or after August 1, 2003, certification offerings from Sun no longer have an expiration date. Rather, certification offerings are based on a version of technology."
  • For exams taken after September 1, 2002, but prior to August 1, 2003, "Recertification was required to maintain one's status as a certified Sun professional after two years."

  • See Sun's Certification FAQ for details.

    Where can I find information about OCPJP testing outside of the U.S.?

    In the top navigation of Oracle's OCPJP page there is an option of "Training Locations" from where you can select your country and find contact information.

    What is the pattern of the expiration date on the exam voucher?

    The pattern of the date on the voucher is MM/DD/YYYY. So if it says 5/10/2009, it means the voucher expires on May 10th, 2009.

    Will I be told how many options to choose in a multiple choice question?

    Yes in the real exam you'll be told how many options to select. The real exam won't have questions like in most mock exams which say "Choose All That Apply". That is done in mock exams to make them difficult.

    Are there any marks for partially right answers?

    There are no points for partially correct answers. If there is a question where you have to select 3 options and you select 2 right and 1 wrong, you'll get no marks for that question.

    What are some potential trips/traps in the OCPJP exam?

  • Two top-level public classes cannot be in the same source file.
  • main() cannot call an instance (non-static) method.
  • Methods can have the same name as the constructor(s).
  • Watch for thread initiation with classes that don't have a run() method.
  • Local classes cannot access non-final variables.
  • Case statements must have values within permissible range.
  • Watch for Math class being an option for immutable classes.
  • instanceOf is not the same as instanceof.
  • Constructors can be private.
  • Assignment statements can be mistaken for a comparison; e.g., if(a=true)...
  • Watch for System.exit() in try-catch-finally blocks.
  • Watch for uninitialized variable references with no path of proper initialization.
  • Order of try-catch-finally blocks matters.
  • main() can be declared final.
  • -0.0 == 0.0 is true.
  • A class without abstract methods can still be declared abstract.
  • Map does not implement Collection.
  • Dictionary is a class, not an interface.
  • Collection (singular) is an Interface, but Collections (plural) is a helper class.
  • Class declarations can come in any order (e.g., derived first, base next, etc.).
  • Forward references to variables gives a compiler error.
  • Multi-dimensional arrays can be "sparse" -- i.e., if you imagine the array as a matrix, every row need not have the same number of columns.
  • Arrays, whether local or class-level, are always initialized
  • Strings are initialized to null, not empty string.
  • An empty string is not the same as a null reference.
  • A declaration cannot be labelled.
  • continue must be in a loop (e.g., for, do, while). It cannot appear in case constructs.
  • Primitive array types can never be assigned to each other, even though the primitives themselves can be assigned. For example, ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error even though longvar = intvar is perfectly valid.
  • A constructor can throw any exception.
  • Initializer blocks are executed in the order of declaration.
  • Instance initializers are executed only if an object is constructed.
  • All comparisons involving NaN and a non-NaN always result in false.
  • Default type of a numeric literal with a decimal point is double.
  • int and long operations / and % can throw an ArithmeticException, while float and double / and % never will (even in case of division by zero).
  • == gives compiler error if the operands are cast-incompatible.
  • You can never cast objects of sibling classes (sharing the same parent).
  • equals() returns false if the object types are different. It does not raise a compiler error.
  • No inner class (non-static inner class) can have a static member.
  • File class has no methods to deal with the contents of the file.
  • InputStream and OutputStream are abstract classes

  • Also see Top Ten Errors Java Programmers Make by David Reilly.

    Am I ready to take the exam?

    The best way to convince yourself that you are ready is to consistently score well on mock exams. In general, most mock exams provide a good indication of how you will score on the real exam. (If anything, the real exams are said to be slightly less difficult than the mock exams. But since the real exam is usually the last one taken after a series of several mock exams, candidates are most prepared for that one.) As a general guideline for confidence, you should consistently score about 10 points higher on the mock exams as you hope to score on the real exam.

    What resources should I study to meet the Objectives for SCJP 310-025 exam?

    SCJP resources based on Sun's objectives, PLEASE NOTE:  These are resources based on an older exam, much of the material is still of great use but bear in mind Cavaet Emptor!

    Section 1 Declarations and Access Control

    Section 2 Flow control and exception handling

  • Exceptions in Java (July 1998) This article gives an in-depth account of exceptions in the Java language and virtual machine.
  • Designing with Exceptions (July 1998) This article discusses design guidelines concerning when and how to use exceptions.

  • Section 3 Garbage Collection

  • Bill Venners Object finalization and cleanup

  • Section 4 Language Fundamentals

  • Object Initialization in Java (March 1998) -- This article describes in detail the process of object initialization in Java programs. It discusses constructors, initializers, instance initialization (init) methods, initialization and inheritance, object images on the heap, and the order in which an object's variables get initialized. It serves as a companion to the regular Design Techniques installment, "Designing object Initialization."
  • Designing Object Initialization (March 1998) -- This installment of Design Techniques begins with a quick look at object design fundamentals, then goes on to discuss various approaches to designing initializers and constructors so as to facilitate the proper initialization of objects.
  • Designing with Static Members (March 1999) -- This article discusses how to use static fields and methods.
  • Inner classes. So what are inner classes good for anyway? (JavaWorld)
  • Java Tip 106: Static inner classes for fun and profit This tip provides an example of using static inner classes to add separate, optional, supplemental functionality to your classes for such things as testing and example code. By John D. Mitchell

  • Section 6 Overloading, Overriding, Runtime Type, and Object Orientation

    Section 7 Threads

  • Sun's tutorial
  • Synchronizing threads in Java
  • Java Threads, By Scott Oaks & Henry Wong Chapter 1. Introduction to Threading

  • Section 8 The java.awt PACKAGE

  • The Event Generator Idiom (September 1998) -- This article discusses how and when to make a Java class observable.

  • Section 9 The java.lang PACKAGE

    Section 10 The java.util PACKAGE

  • Introduction to the Collections Framework. Short Course By MageLang Institute
  • Using Collections with JDK1.2 by Glen McCluskey

  • Section 11 The PACKAGE

  • Top Ten Myths about Java I/O by Elliotte Rusty Harold
  • Examples from Java I/O (from "Java I/O" By Elliotte Rusty Harold)

  • char a = '\u000A'. Why is this invalid?

    Unicode escape characters of the form '\Uxxxx', where xxxx is a hexadecimal value, are processed very early in the translation process (see JLS 3.10.4 ). As a result, the special characters '0A' (line feed) and '0D' (carriage return) are interpreted literally as "end of line."

    For example, the expression...

    ...therefore becomes...

    ...which results in a compile-time error.

    To avoid this error, always use the special escape characters '\n' (line feed) and '\r' (carriage return).

    What are the Java standard keywords? Are true, false, and null keywords?

    Java keywords are listed in the Java Tutorial:

    "true, false, and null are not keywords but they are reserved words, so you cannot use them as names..."

    What does strictfp mean?

    The strictfp modifier can be used with top-level classes, nested classes, nested interfaces, and method declarations. It can not be used with variables, constructors, or initializer blocks. It also cannot be combined with the abstract modifier.

    If an expression is FP-strict, all intermediate values should fit into the range for float or double variables. If an expression is not FP-strict, there are no such restrictions.

    A non-constant expression is considered FP-strict if any of the class, interface or method declarations that contain the expression have the strictfp modifier.

    Is it allowed to declare the main method private?

    Former JVM versions (pre-1.4) allowed the main method to have any accessibility (private, etc). This incompatibility with Section 12.1.4 of the Java Language Specification has been fixed as of version 1.4. In order to invoke a main method from the command-line, it is now mandatory to declare the main method as follows:

    If the main method has any access level other than public, it will no longer run from the command-line.

    Can I have more than one class in a .java source file?

    Yes. However, each .java source file can contain at most one top-level class (or interface) definition that is public. If a top-level public class (or interface) definition is present, then the .java source file must share that name exactly (matching case).

    Can static methods be overridden?

    static methods cannot be overridden, but they can be hidden (if not final). See Overriding vs Hiding for details.

    How can you compare NaN values?

    Except for NaN, floating-point values are ordered; arranged from smallest to largest, they are negative infinity, negative finite nonzero values, negative zero, positive zero, positive finite nonzero values, and positive infinity.

    NaN is unordered, so the numerical comparison operators <, <=, >, and >= always return false if either or both operands are NaN. The equality operator == returns false if either operand is NaN. The inequality operator != returns true if either operand is NaN. In particular, x != x is true if and only if x is NaN, and (x == y) will be false if x or y is NaN.

    For any value of x, including NaN itself, each of the following comparisons will return false.

    Double.NaN != Double.NaN will always return true.

    Note: The above relationships involving Double.NaN also apply to Float.NaN.

    Are string literals eligible for GC?

    The objects created in the String pool are not subjected to GC until the class is unloaded by the JVM. They get discarded at that time or just before the virtual machine unloads the class' bytecode. For the purpose of the SCJP exam, you are not required to know the details of String pool memory management.

    How does InterruptedException affect a thread?

    All InterruptedExceptions are caused by interrupt() method calls, (although not all interrupt() calls cause InterruptedExceptions). The effect differs depending upon in which state a target thread is. When a thread is:

  • in running state: No exception is thrown. However the interrupted flag is set, which means that if you call interrupted() or isInterrupted(), they will return true. It is up to the running target thread to check the flag and to take some action, but it is perfectly possible to ignore this flag. If the thread later goes from running state to waiting or sleeping state before interrupted flag is cleared via interrupted() method, then an InterruptedException will be thrown and the flag will be cleared.
  • in waiting/sleeping state: The thread moves into ready state, and when it next gets a chance to execute an InterruptedException is thrown. No flag is set, so interrupted() returns false.
  • in ready state: If an interrupt() is called while a thread is in ready state, nothing happens until the thread moves back to running state. Once the thread has moved to running state, then see answer for running state, above.

  • Summarizing, interrupt() does not stop the target thread, in other words, there is no guarantee that a thread on which interrupt() was invoked will be stopped. Nevertheless, interrupt() method call may stop a thread, depending on circumstances listed above.

    What are the important I/O constructors and methods?

  • Hierarchy of IO classes.
  • The interfaces and abstract classes, as well as the concrete classes implementing these.
  • The "chaining" of one stream to another to achieve the desired result. (Given a requirement, you should be able to choose the best possible way to chain streams together.)
  • Different character encodings, and the IO classes capable of making use of the encoding specifications.
  • How FileInputStream, FileOutputStream, RandomAccessFile may be constructed using File or String arguments.
  • The PrintStream class and the overloaded println() methods defined in it. The autoflush mechanism.
  • The RandomAccessFile class (pay attention to the constructor and the methods to move your file pointer back and forth). You should be able to calculate how many bytes the pointer moves when you read/write different data types. Know the two possible arguments that control read/read-write access to a RandomAccessFile.
  • The hierarchy of IOExceptions, and the methods in the IO classes that throw exceptions.
  • The File class, including all the overloaded constructors and various methods that permanently affect the underlying file system, and that determine various properties of the underlying file.

  • getCanonicalPath() returns an absolute pathname in which all relative references and references to the current user directory have been completely resolved.

    getAbsolutePath() returns the absolute pathname which is a concatenation of the current user directory, the separator character, and the pathname of the file object.

    The absolute path includes the drive name and the top-level directories, as well as the file name itself. All canonical paths are absolute (but not all absolute paths are canonical). A single file existing on a system can have many different paths that refer to it, but only one canonical path.

    Let's suppose there are two directories in Windows:


    And there is a file in OneDirectory named MyFile. Then we can specify this file in a variety of ways (note that the File class interprets the Unix and Windows path separators '/' and '\' the same, except that '\' must be represented with the escape sequence '\\' in a String):

    In Java under Windows, all the above are possible absolute paths for the same file. But since they all refer to the same file, that file is represented by one and only one canonical path:

    The canonical form ensures that you can compare safely two file paths, i.e. if they point to the same file or directory, they will be equal.

    Also note that getCanonicalPath() method may throw an IOException because the construction of the canonical pathname may require file system queries, whereas getAbsolutePath() never throws an exception.

    Could someone explain the Regex2 class from K&B's Java 5 Study Guide?

    There is some confusion regarding the following class (from the SCJP Sun Certified Programmer for Java 5 Study Guide by Katherine Sierra and Bert Bates)...

    When this is compiled and run with java Regex2 "\d*" ab34ef the output is 01234456, which prompts the question: "Where does the '6' come from?"

    The asterisk (*) is a "greedy quantifier," specifying that whatever preceeds it (in this case, any digit) should be matched zero or more times. By allowing for zero occurrances, a match of zero length is possible. Because a match of zero length is possible, the find() method will check the index following the last character of input.

    Note that for a match of zero length, the matcher's start() and end() methods both return the same index. In these cases, the group() method returns an empty String (i.e., the substring from start() to end()).

    So in the above example, the find() method locates the following matches:

    For more detailed information, see this Sun/Oracle tutorial on regex quantifiers.

    How many String objects are there? What is the String pool?

    See Corey McGlone's article Strings, Literally .

    Why do separate autoboxing conversions sometimes return the same reference?

    Two autoboxing conversions of a primitive value p will yield an identical reference (that is, the == comparison will return true) if p is:

  • true or false
  • a byte
  • a short or int in the range of a byte (-128 to 127)
  • a char in the range of \u0000 to \u007f (0 to 127)

  • Note: The Java Language Specification does not explicitly guarantee this behavior for long values within the range of a byte.

    For additional details, see JLS section 5.1.7 Boxing Conversion .

    What is a most-specific method?

    Suppose that more than one version of an overloaded method applies to a particular call. For example, suppose that Cat extends Animal, and a method is overloaded to take either of these types as an argument.

    Further, suppose that "milton" references an instance of Cat. That is...

    Now, since a Cat is also an Animal, which method will be invoked with the following call?

    In this situation, Java invokes the "most-specific" method, as detailed in section of the Java Language Specification. In general, one method is considered more specific than another if its argument types are subtypes of the other method's respective argument types. So because Cat is a subtype of Animal, the method overloaded to accept a Cat is more specific than the method overloaded to accept an Animal. Therefore, method(Cat cat) will be invoked by the call method(milton).

    If it's not possible to identify a most-specific method from among the applicable methods, then the invocation is considered "ambiguous" and results in a compile-time error.

    Note, however, that a null reference could apply to any object type. Therefore, the call method(null) would also invoke the most specific method -- in this case, method(Cat cat).

    Why are the notify, notifyAll and wait methods defined in the Object class instead of the Thread class?

    See this thread and this thread for answers.

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


  • Add question about Sun logo use: How to register, how long it takes, etc.

  • CategoryFaq CategoryCertification
    1 week ago
    Welcome to CodeRanch!

    I've added the first two the errata list. For the third, it was right in the version we submitted. We even used the metadata so it would show up as a checkbox. I'm working with the publisher on what happened in between.
    Yes this is the correct forum for both errata or asking questions about the book exam.

    Since Campbell, mentions the Java Language Specification, it says:

    In the book we called "for update" an increment clause to make it easier to remember. The question is differentiating between a traditional for and a while loop.  I put it on our private list of things to consider clarifying for the next book. I don't consider it an errata though.

    Note: On the real exam, you are always told how many questions are correct. So less questions depend on parsing English/intent. Also, on the real exam, the most logical understanding of a sentence is correct. You don't want to get a question wrong because you read into it!
    On the real exam, your answers are saved each time you progress to the next question. You can go back and changed any of them until you submit the full exam.
    Thanks. I added #2 and #3 to the errata. For #1 and #4, i added them to our private list of stuff that could be clearer, but isn't quite wrong.
    That's from my book.

    I think your example is more like our example #2:

    Which we note does compile because the type is declared outside the loop. (well for one of the two)
    1 week ago
    See our BookPromotions2018Winners

    January 8Electron in ActionSteve KinneyManningSalvin francis , Paul Anilprem , Tony Esposito , charles rossSent in winners (1/20/19)
    January 15
    Hands-On Software Engineering with PythonBrian AllbeePacktPaul Nisset, Carl Byrd, Scott Mac Donald, Campbell RitchieSent in winners (1/20/19) (Carl Byrd received)
    January 22
    Get Programming with Java (MEAP only)Peggy FisherManningtangara goh, Manos Marketos, Fred Kleinschmidt, Daniel AnderssonSent in winners (1/28/19)
    January 29Java in a NutshellBen Evans & David FlanaganO'ReillyWill Myers , Vanessa Williamson, Dave Tolls , Cezar ApulchroWinner reported received (3/1/19)
    February 12Java XML & JSONJeff FriesenApresspaul nisset, Carl Byrd, Jorge Ruiz-Aquino, ludoviko azuajeWinner reported received (2/25/19) (Carl Byrd received)
    February 19Kotlin for Android App DevelopmentPeter SommerhoffAddison-Wesley ProfessionalSean Corfield, Dave MacLean, Terry Broman, paul nisset, Rania BradburyWinner reported received (4/9/19)
    February 26Head First KotlinDawn & David GriffithsO'ReillyWill Myers, Celso Furtado, Al Hobbs, Ron McLeodWinner reported received (3/29/19) (Ron McLeod)
    March 12Core Java, Volume II--Advanced FeatureCay HorstmannPrentice HallStephan van Hulst, Zulfi Khan, paul nisset, Tim HollowayWinner reported recieved (4/9/19)
    March 19Python Continuous Integration and DeliveryMoritz LenzApresslRogerio Kioshi, Travis Risner, M Khalid, Carl ByrdWinner reported received (10/9/19)     (M Khalid Received)
    March 26Head First GoJay McGavrenO'ReillyRyan Jumawan, Timur Radzhabov, Rob Spoor, Will MyersWinner reported received (4/5/19) (Rob Spoor)
    April 9Servless Programming CookbookHeartin KanikathottuPacktLanny Gilbert, Lucian Revnic, Liutauras Vilda, Billy TsaiSent in winners (5/8/19)
    April 16Production Ready Serverless (Video)Yan CuiManningCarl Byrd, Timur Radzhabov, Divya Shiv  Sent in winners (5/8/19)
    April 23Serverless Applications with Node.jsSlobodan Stojanovic  & Aleksandar Simovic  Manningsourabh girdhar, Tim Holloway, Noorul Hameed, saad el khlifiSent in winners (5/8/19)
    April 30Natural Language Processing in ActionHobson Lane, Hannes Hapke & Cole HowardManningpaul nisset, Claude Moore, Carl Byrd, Christian NicholsonSent in winners (5/18/19)
    May  14Building Ethereum DAppsRoberto InfanteManningMichael Krimgen, Joe Cortee, paul nisset, ludoviko azuaje  Sent in winners (5/18/19)
    May  21Grokking BitcoinKalle RosenbaumManningHimanshu Ahuja, Carl Byrd, Timothy Richards, Tim MooresWinner reported received (6/19/19) (Tim Moores)
    May  28The Well-Grounded RubyistDavid A. Black & Joseph Leo IIIManningAnna Baik, meenakshi sundar, Tony Esposito, Sam MaghettWinners sent to publisher (6/18/19)  Received 6/20/19 (Anna Baik), Received 6/27/19 (Tony Esposito)
    June 4Classic Computer Science Problems with PythonDavid KopecManningTim Holloway, D.J. Quavern, Piet Souris, Tony Esposito Sent in winners (7/17/19)
    June 4The Joy of JavaScriptLuis AtencioManningSunderam Goplalan, Carl Byrd , satya Priya Sundar, Timur RadzhabovSent in winners (7/17/19)
    June 11Programmers Guide to Apache ThriftRandy AbernethyManningTimur Radzhabov, Carl Byrd, Tim Moores, Randy TongSent in winners (7/17/19) Received ebook 7/18/19 (Randy Tong, Tim Moores)
    June 25Java Database Connections & Transactions (e-book only)Marco BehlerSelf PublishedDinkar Chaturvedi, genos raman, Salil Wadnerkar, Ray JenderWaiting on winners info
    July 9Learn Data Structures and Algorithms with GolangBhagvan KommadiPacktRhul Kug, Devanshi Arora, Stephane Clinckart, Shikhar Vinesh SinghSent in winners info (9/4/19)
    July 30Reactive SpringJosh LongLean PublishingBaskar Krishna, Wirianto Djunaidi, Ravi Desai, Chintan SanghaviSent in winners info (9/4/19)
    August 13Cloud Native PatternsCornelia DavisManningMatthew Keller, paul nisset, Carl Byrd, Liutauras VildaWinner reported received 9/4/19
    August 13Natural Language ProcessingHobson Lane, Hannes Hapke  and Cole HowardManningCarl Byrd, Terseer Anthony ShaguySent in winners info (9/4/19)
    August 20Event Streams in ActionAlexander Dean & Valentin CrettazManningBabi Astimal Astimal, Stephan van Hulst, Raghunatha Reddy, Marco Schoolenberg  No winners replied
    August 27Phoenix in ActionGeoffrey LesselManningTimur Radzhabov, Milan Bhagwat, Carl Byrd, ludoviko azuajeWinners sent in 9/22/19
    September  3The Java Module SystemNicolai ParlogManningSai Hegde, Will Myers, satya Priya Sundar, Piotr NowickiWinners sent in 9/22/19
    September  10OCP Oracle Certified Professional Java SE 11 Programmer I Exam Fundamentals 1Z0-815 (e-book)Hanumant DeshmukhEnthuwareRanjith Kumar Kumar, Geff Chang, Adrian Grabowski, Elias Khan  Winners sent in 9/22/19 (Geff Chang received)
    October 1Graph AlgorithmsMark Needham & Amy HodlerO'ReillyD.J. Quavern , Gary W. Lucas , Awais Bajwa , Tim HollowaySent in winners 10/24/19
    October 8Programming Quantum Computers: Essential Algorithms and Code SamplesEric Johnston, Nic Harrigan & Mercedes Gimeno-SegoviaO'Reilly[M Mohil, , Mainak Biswas, Stephan van Hulst,Erron Austin  Sent in winners 10/24/19
    October 15Reactive Streams in Java:  Concurrency with RxJava, Reactor, and Akka StreamsAdam DavisApressRodrigo Lopes, Will Myers, paul nisset, Dinkar ChaturvediSent in winners 10/24/19
    October 22Machine Learning with R: Expert techniques for predictive modelingBrett LantzPacktSudd Ghosh, paul nisset, Vaseem MohammedWinners sent 11/11/19)
    October 29Java 13 Revealed: For Early Adoption and MigrationKishori SharanApressSalvin Francis, Serge Yurk , Campbell Ritchie , Robert IngmarssonWinners sent 11/11/19)
    November 5Pivotal Certified Professional Core Spring 5 Developer Exam: A Study Guide Using Spring Framework 5/Iuliana CosminaApressCharles O'Leary, Geff Chang, Saket Barve, Shaik AshishWinner reported received 1/7/2020)
    November 12Emmy in the Key of CodeAimee LucidoVersifymeenakshi sundar, Brian Burress, Shaik Ashish, Junilu LacarWinners sent 12/11/19
    November 19OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815Jeanne Boyarsky & Scott SelikoffSybexNamith Kumar, Salil Wadnerkar, Aysenur Eroglu, Shaik AshishWinner reported receiving e-book (1/6/20)
    December 3Learn Java with MathRon DaiApressDanielle Beard, Piet Souris, Junilu Lacar, Lokeshwar TailorWinners sent 1/21/20
    December 17DevOps ParadoxViktor FarcicPacktludoviko azuaje, Carl Byrd, Junilu LacarWinners sent 1/21/20
    December 17Pro Spring SecurityCarlo Scarioni & Massimo Nardone  ApressClaude Moore, Tim Holloway , Abhra Kar, ludoviko azuajeWinner reported received (e-book) 1/7/20

    Note: All dates in mm/dd/yyyy format

    Go back to the main BookPromotions page.

    For questions about this page or to schedule a promotion, contact: bookpromotion AT javaranch DOT com
    1 week ago
    The rules depend on the publisher. I suspect most publishers don't ship review copies to Malaysia. Which means you'd get an e-book.
    2 weeks ago