Help coderanch get a
new server
by contributing to the fundraiser

SimonJ Birch

+ Follow
since Jun 01, 2006
Merit badge: grant badges
For More
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by SimonJ Birch

Another thought.....I thought that the main method would be at the bottom of the call stack and therefore couldn't declare a throws exception. Or does it simply throw the exception to the superclass, in this case Utils?
I am also confused by 'Declare that Ping.getInt() throws an Exception' as I can see no method call named Ping.getInt() in the program.
Thanks for your reply, Wise

I guess where I am getting confused is in my understanding of the phrase 'Wrap the invocation of getInt() in a try / catch block'. Which line is this referring to?
Hi everyone,

I've just worked my way through the problem below from the K & B study guide SJCP 5:

8. Given:
1. class Ping extends Utils {
2. public static void main(String [] args) {
3. Utils u = new Ping();
4. System.out.print(u.getInt(args[0]));
5. }
6. int getInt(String arg) {
7. return Integer.parseInt(arg);
8. }
9. }
10. class Utils {
11. int getInt(String x) throws Exception { return 7; }
12. }
And the following three possible changes:
C1. Declare that main() throws an Exception.
C2. Declare that Ping.getInt() throws an Exception.
C3. Wrap the invocation of getInt() in a try / catch block.
Which change(s) allow the code to compile? (Choose all that apply.)
A. Just C1 is sufficient.
B. Just C2 is sufficient.
C. Just C3 is sufficient.
D. Both C1 and C2 are required.
E. Both C1 and C3 are required.
F. Both C2 and C3 are required.
G. All three changes are required.

I can't understand why the correct answers are A and C (my choice was C). I can't follow their reasoning either for the answer!

Can anyone explain the rationale behind the answer?


That makes it clearer.

Thanks Shuba

I've got a query regarding calling a static method from the main method. Why in this program is the method FizzSwitch() static.....

class Fizz {
int x = 5;
public static void main(String[] args) {
final Fizz f1 = new Fizz();
Fizz f2 = new Fizz();
Fizz f3 = FizzSwitch(f1,f2);
System.out.println((f1 == f3) + " " + (f1.x == f3.x));
static Fizz FizzSwitch(Fizz x, Fizz y) {
final Fizz z = x;
z.x = 6;
return z;

....when in this program....

class Eggs {
int doX(Long x, Long y) { return 1; }
int doX(long... x) { return 2; }
int doX(Integer x, Integer y) { return 3; }
int doX(Number n, Number m) { return 4; }
public static void main(String[] args) {
new Eggs().go();
void go() {
short s = 7;
System.out.print(doX(s,s) + " ");

... the method go() isn't static even though it is being called from main?


Good find, Marcus!

That five quid one must have gone but this is a great site to come back to....I've added it to my favourites.


I just wanted to qualify the last sentence of my last reply. I was referring to the 'Boot Camps' when I said that I share my reservations, in case there is any misunderstanding!
Thanks for the replies!

Keith, yes you can order it from but not, it seems, from The time and expense of ordering from the U.S. site made it prohibitive as I needed the book quickly.

Marcus, your reply gives me an opportunity to thank you for all the assistance that your mock exams have given me in preparing for the exam. Computeach recommends that people visit your site and take your three mock exams in preparation for the real thing!

Computeach specialises in distance learning courses. Their material is a mixture of online learning and bespoke written material. As I am presently studying with them, I do not want to pass comment about their courses. I know of the 'boot camp' courses you talk about although Computeach doesn't provide those. I share your reservations about them.

You can see some material on the JDK 1.4 objectives at

And you are very likely to be able to get the S&B 1.4 book from (possibly even second hand which should be a competitive price). Once a new version of an exam comes out sales of the older versions tend to diminish of course.

What is the Computeach course like? I have always been frustrated when I see Certification courses as they almost always cover material not on the exam. An example of this was (and still is I suspect) that the official Sun one week courses cover material not on the exam. When you are paying a big chunk of money out for only five days I would want to stay narrowly focussed on the exam topics [/rant]

You might also like to read this document that describes some of the new features of the JDK1.5 exam (so you know what to ignore if you are using a JDK 1.5 book)

[ June 01, 2006: Message edited by: Marcus Green ]
I have just purchased SCJP 5 by Bert Bates and Kathy Sierra.

The only thing is that I am studying for the 1.4 exam through an orgainsation called Computeach who are not yet allowing their candidates to take the 1.5 exam subject to updating their learning material. I live in the UK and have found the older corresponding edition difficult to obtain online.

I would like to obtain the relevant information in the 1.4 edition pertinent to the 1.4 exam (e.g. bitwise operators).

Does anyone know how I can obtain those chapters to supplement the new edition of the SCJP book.

Note to Kathy and Bert if you are reading this:

Please would you ask your publishers to encourage booksellers to sell previous editions of your exam books (in the U.K. at least) for those of us who are taking the older exams.