Please use the SCJP forum to post your own question - ScjpWallOfFame
SCJP FAQ Contents
Questions about Sun Resources
General Questions about the Exams
Questions about Exam Preparation (Books, Notes, Mock Exams, etc.)
Questions on Specific Topics
Where can I find the official SCJP FAQ from Sun?
http://www.sun.com/training/certification/faq/#java
What are the SCJP objectives?
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 1.5, then you can take the SCJP 1.5 Upgrade exam.
For more information see:
What is the best way to prepare for the SCJP 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 SCJP 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 SCJP?
- One of the most popular (and recommended) books is: SCJP Sun Certified Programmer for Java 5 Study Guide by Katherine Sierra and Bert Bates (K&B). The publisher is McGraw Hill Osborne Media -- ISBN 0072253606.
- Check the JavaRanch Bunkhouse for additional recommendations and reviews.
Where can I find the Java Language Specification?
Also see the JLS Maintenance Page for changes, clarifications, amendments, etc.
Where can I find the Java API documentation?
What are some mock exams available?
Where can I find preparation notes?
SCJP 1.5:
SCJP 1.4:
SCJP 1.2:
Various Versions:
Are there supporting courses for preparing the exam?
Are there any mock exams that allow Exam Objectives section-wise tests?
How is the SCJP 1.4 exam different from the SCJP 1.2?
- Exam objectives: AWT and IO have been dropped. Assertions and Wrapper classes have been added. A deeper understanding of the Collections Framework is required (e.g., using hashCode and equals).
- Number of questions: 61
- Time: 120 minutes (same as 1.2 exam)
- Passing score: 52% (reduced from 61%)
- Level of difficulty: Sun indicates that it is more difficult.
- Format of questions: As on the 1.2 exam, most questions (an estimated 80-90%) still have code samples 6-30 lines long. Multiple choice questions may have more than 4 options, but you will always be told how many options to choose.
How is the SCJP 1.5 exam different from the SCJP 1.4?
- Exam objectives: Several important new language features have been added, including enums, generics, static imports, and autoboxing/unboxing. API features added to the exam include java.lang.StringBuilder, java.util.Locale, java.util.Formater, java.util.Scanner. java.util.regex.Pattern, and java.util.regex.Matcher. Java IO features have been added, including File, BufferedReader, BufferedWriter, FileReader, FileWriter and PrintWriter. Concepts such as loose coupling and high cohesion have been added, as well as greater emphasis on encapsulation as it relates to JavaBean conventions. Bit manipulation (e.g., shifting) has been dropped.
- Number of questions: 72 (increased from 61)
- Time: 175 minutes (increased from 120 minutes)
- Passing score: 59% (increased from 52%)
- Level of difficulty: The concensus is that it is more difficult.
- Format of questions: As before, you will always be told how many options to choose. No credit is given for partial answers. Drag-and-drop questions were also introduced for this version of the exam.
How is the SCJP 1.6 exam different from the SCJP 1.5?
- Exam objectives: Several new API classes/interfaces have been added: java.io.Console, java.util.NavigableSet, java.util.NavigableMap. Explicit garbage collector calls (i.e. System.gc()) will no longer be tested, but candidates will still be expected to understand garbage collection and the finalize() method. Also, the following topics will be tested in greater depth: exception handling, collections, assertions, threads, and flow control. See the SCJP forum for more details.
- Number of questions: 72 (no change)
- Time: 210 minutes (increased from 175 minutes)
- Passing score: 65% (increased from 59%)
- Format of questions: No change.
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 2 weeks before retesting. See Sun's FAQs for more details.
What are some potential trips/traps in the SCJP 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.
- RandomAccessFile descends from Object and implements DataInput and DataOutput.
- 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 can have a static member.
- File class has no methods to deal with the contents of the file.
- InputStream and OutputStream are abstract classes, while DataInput and DataOutput are interfaces.
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.
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...
char A = '\u000A';
...therefore becomes...
char A =;
...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: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
"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:
public static void main (String[] args)
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.
x < Double.NaN
x <= Double.NaN
x == Double.NaN
x > Double.NaN
x >= Double.NaN
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.
- The DataInput/DataOutput streams. (How data is written/read back from these streams. How many bytes are actually read/written by different overloaded read() and write() methods.)
- 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:
c:\OneDirectory
and
c:\AnotherDirectory
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):
c:\OneDirectory\MyFile
c:\AnotherDirectory\..\OneDirectory\MyFile
c:/OneDirectory/MyFile
C:\ONEDIRECTORY\MyFile
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:
C:\OneDirectory\MyFile
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.
How long will my certification last before expiring?
- "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 SCJP testing outside of the U.S.?
Near the upper right corner of Sun's SCJP page is a link for "Training outside the U.S." Clicking on this link will open a window in which you can select your country. This will take you to a page of contact information.
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)...
import java.util.regex.*;
class Regex2 {
public static void main(String [] arg) {
Pattern p = Pattern.compile(arg[0]);
Matcher m = p.matcher(arg[1]);
boolean b = false;
while(b = m.find()) {
System.out.print(m.start() + m.group());
}
}
}
When this is compiled and run with java Regex2 "\d*" ab34ef the output is 0123456, which prompts the question: "Where does the '6' come from?"
Added 18.03.08
The output is actually: 01234456
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:
start end group
index index
0 0 empty
1 1 empty
2 4 34
4 4 empty
5 5 empty
6 6 empty
For more detailed information, see this Sun 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.
void method(Animal animal) {...}
void method(Cat cat) {...}
Further, suppose that "milton" references an instance of Cat. That is...
Cat milton = new Cat();
Now, since a Cat is also an Animal, which method will be invoked with the following call?
method(milton);
In this situation, Java invokes the "most-specific" method, as detailed in section 15.12.2.2 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 an answer.
ToDo
- Add question about Sun logo use: How to register, how long it takes, etc.
- Add question about using Sun's Certification Manager.
CategoryFaq CategoryCertification
|