This week's book giveaway is in the Functional programming forum.
We're giving away four copies of Functional Design and Architecture and have Alexander Granin on-line!
See this thread for details.
Win a copy of Functional Design and Architecture this week in the Functional programming forum!

Douglas Chorpita

Ranch Hand
+ Follow
since May 09, 2006
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 Douglas Chorpita

Most of the exceptions in java.lang are run-time exceptions. The most noteworthy non-run-time is InterruptedException, which is very important to know for some of the Thread/Object synchronization methods (sleep, join & wait).

People studying for the SCJP should also learn to look directly at the source code. As a picture is worth a thousand words, a java.lang source file is worth is thousand explanations.

I passed (95%) the SCJP 1.4 last week.

I logged into the certmanager (password, etc.) and could verify my test result.

The page inside the certmanager allows one to "Get Logos".

But when I go into the logo area, the page is more or less empty.

How are we supposed to get the logos?
About 8 weeks (10 weeks, but with a two-week vacation squeezed in between).

But I studied about 25 hours a week in those 8 weeks (I teach part-time right now so I have lots of free time). So it was about 200 hours of concentrated preparation.

It is conceivable that for a very busy person (full-time worker? wife and kids?) it might take more than a year to get these 200 hours.
15 years ago
I took the exam this morning.

I was really nervous before the test.

I was in Europe on Monday and flew in for the exam. The jetlag really had me scared. Yesterday my brain was not working at all. I looked at code samples and it all seemed like some strange unknown language. Fortunately my brain began to work again this morning.

The exam process was nerve-wracking. The staff member was 15 minutes late for work, so I was forced to wait nearly 45 minutes before I could start my test. It seemed like a week went by in those 45 minutes.

The marker pen that I received to work out problems was out of ink. When I signaled for assistance (you are not supposed to leave the exam room), no one came to help me. I lost about 10 minutes due to the lack of attentiveness of the Prometric staff.

But the exam itself seemed pretty easy, especially compared to some of the harder mocks out there. I had lots of time at the end. This was good. I could go back and review all of my initial answers. I think I corrected 2 or 3 mistakes in this phase.

Many thanks to Bert Bates and Kathy Sierra (Sun Certified Programmer & Developer for Java 2 Study Guide ... the "must-have" book ), Marcus Green (Mock Exam), Dan Chisholm (massive battery of mock exams in every category ... this was great), Ashish Hareet (Voodoo exams).

Are there any stats on what these scores mean? Percentile rankings?

I imagine that 95% is not too shabby, especially for a C++ guy. Maybe I should teach Java as a career? Any thoughts or feedbacks from anyone?

I was a senior software developer for 15 years, but took 5 years off to study linguistics in a foreign country. In a few months, I will start looking for a real job. That's why I took this exam.

I hope this will help me a lot with landing job interviews. Any thoughts? Should I list my score on my resume? Or it is taboo to list scores? I have seen different opinions.

Nice to be finished. Nice to be able to relax again.
15 years ago
The anonymous class is a subclass of the class Bar, not the class Sample.
If an exception is not caught, the finally is executed, but all other code is skipped.

Here, in your example, the exception IS being caught. If an exception is caught, code flow returns to normal.

m1() throws an exception, but it catches it. So code flow returns to normal. Then m2() is run. It throws another exception, which is not caught in m2(). The finally-block runs anyway, as the finally block ALWAYS runs. The code jumps ahead to the next catch-block in main() where it is caught. After this, code flow returns to normal. Program exits without an error.

If there would be a method, say m3(), called after the call to m2(), this call would be skipped.

You can have nested try-catch-blocks. When an exception is thrown, the remainder of the try-block is skipped. If the exception is not caught, the finally-block (if there is one) ALWAYS runs. Once this try-catch-block is finished, one might still be in a higher-level try-catch-block. In this case, the remainder of the higher-level try-block is skipped. There is another chance for catch or finally (or both). There can be many levels of try-catch.

[ July 29, 2006: Message edited by: Douglas Chorpita ]
Sorry. My fault.

I was doing a bunch of tests, all in one file.

I had created a class called "Object" in my own package. I know this is stupid, but I wanted to see (with my own eyes) that a class called "Object" would compile and extend "java.lang.Object".

This is why I got the error.

Thanks for the help!!!
In Java, an Monkey array can be assigned to an animal array.

The following code is legal:

Java doesn't allow this, however. Why? Is "Object" a special case?

This is a special syntax allowed by Java.

String [] array = { "A", "B", "C" };

is really the same as:

String [] array = new String[] { "A", "B", "C" };

If you think about it, most of the time, when we create an array, its instance type (here String[]) is the same as the reference type (also String[]). So this is a "shortened syntax".

So, although the syntax doesn't EXPLICITLY show it, there is a String array being instantiated and put on the heap. The String objects, because they are not created with the new operator, will be put in the String literal pool. But they also wil be instantiated (not on the heap, rather in the literal pool). The char[] arrays for these literal strings are also put on the heap.

For more on this topic, read:

About Strings
[ July 28, 2006: Message edited by: Douglas Chorpita ]

The book (p. 529 in 1.4 book) fails to point out this problem.

I guess the example is very basic, so as to not overwhelm the reader.

In the following book example, both threads are in an infinite loop. In this case, it doesn't matter which thread gets the lock first. If the notifying thread notifies the other thread before it starts waiting, it will notify it again the next time through the loop.
Perhaps an easier example:


Start: 255 Decimal -> 0000 0000 1111 1111 Binary -> 00FF Hex
Flip: -256 Decimal -> 1111 1111 0000 0000 Binary -> FF00 Hex
+1: -255 Decimal -> 1111 1111 0000 0001 Binary -> FF01 Hex
narrow to byte -> 0000 0001 Binary -> 01 Hex -> 1 Decimal

if( (byte) -255 == (byte) 1 )

One more time:

Decimal -1001 -> Binary 1111 1100 0001 0111 -> Hex FC17 (see above)
Narrowed to byte -> Binary 0001 0111 -> Hex 17

Hex 17 = 1 x 16 + 7 = Decimal 23
Why can nested interfaces use the modifier "strictfp"?

Is there a logical explanation for this?
-1001 fits in a short, so we calculate with a short.

Decimal 1001 -> Binary 0000 0011 1110 1001 -> Hex 03E9
Flip -> Binary 1111 1100 0001 0110 -> Hex FC16
Add One -> Binary 1111 1100 0001 0111 -> Hex FC17
Decimal -1001 -> Binary 1111 1100 0001 0111 -> Hex FC17
Shorten to byte -> Binary 0001 0111 -> Hex 17

Hex 17 = 1 x 16 + 7 = 23