Beginning next week I will take a more detailed look at the three types of questions you will encounter on the Sun Certified Java Programmer exam: “Results,” “Drag and Drop,” and “Complete the Code.” These posts will be ideal for you if you are thinking about taking or have already started preparing to take the SCJP. Each post will include guidelines for identifying the type of question, variations of the question that you might come across, the types of answer choices that will be given, the best strategies that I have found for solving the question, and some original examples so that you get comfortable with the various strategies.
You will not find the material I present here in any test prep book. I’m not going to try to teach you what to study – you can get that information from any decent test prep book. Rather, I’m going to teach you how to study and how to approach the test so that you have the best possible chances for success.
To kick things off, here are ten of the most important things to remember while taking the SCJP exam, regardless of the question type.
- Always look at access modifiers first. If the modifiers aren’t compatible, you don’t even have to look at the rest of the code.
- Always make sure that all checked exceptions are either declared by the method or caught in the method, but don’t be tricked into choosing “Does Not Compile” when a RuntimeException is not declared or caught!
- Make sure you understand the difference between “correct use” and “appropriate use.” “Correct use” of assertions means no compilation errors. “Appropriate use” of assertions means that assertions are used as Sun’s coding standards suggest they should be used.
- Make sure you understand the difference between compiler errors and compiler warnings. Don’t even think about warnings unless the question specifically mentions them.
- Know the difference between statements that will cause an exception to be thrown and statements that will cause a compilation error. You will frequently have to decide between the two.
- If “Compilation Fails” is an answer choice, make sure you read every line of code, even those which will never be executed.
- If “Compilation Fails” is not an answer choice, read the code as if you were a JVM – starting from main. Code that won’t be executed doesn’t matter, don’t let it confuse you.
- Switch statements are implicit assignments. Make sure every case constant can be assigned to the object being switched on without an explicit cast. Otherwise, the code won’t compile.
- When there are multiple methods that might fit a call, the JVM will choose the first one based on the following order: first it will attempt to widen the aguments (ie: Integer→Number); second it will try to box the arguments (ie: int→Integer); third it will try to box AND widen the arguments (ie: int→Integer→Number); finally it will try to use var-args.
- Modifiers can be implicit in interfaces: methods are ALWAYS public and abstract, variables are ALWAYS public, static, and final, even if they aren’t explicitly stated.
Have something to say about this post? Let me have it!