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.
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.
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 email@example.com 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."
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.
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.
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.
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
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...
...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?
"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:
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 126.96.36.199 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?