SCJP Sun Certified Programmer for Java 6 Exam 310-065

Author: Katherine Sierra, Bert Bates
All Stack Overflow 16


by anonymous   2017-08-20

I have a little book with "Exam Cram" in its title. The emphasis is on "little;" you can read through it in a single evening. It describes in prose all the important features of Java, it contains tables of quick facts that will be essential, and it covers, briefly, all of the SCJP exam.

For the less than eidetic, it gives hints on how to write yourself a crib sheet from memory once the test starts (meaning you can carry a bit of what you need to know in short-term memory). There are also some tips on pitfalls and such. Finally, and perhaps most importantly, there is at least one practice exam in it (haven't looked at it in a while) and a bunch of drill questions.

Alas, from what I see at Amazon, the book I recommended only covers Java 2: Still, there are bound to be similar, more timely books.

This one: by Kathy Sierra is similar and about Java 6.

Some people would (and in fact did) recommend buying a general purpose Java book. Ideally, all you should have to do is learn "all of Java" and then you'd be ready for the exam. But this is not a winning strategy!

related anecdote

The first time I took my driver's test with the DMV, I had a long wait and quickly skimmed through a little info booklet they provided. I easily scored 100.

I later had to take the test again. Knowing the test was laughably easy, I spurned the booklet and failed the theoretical test. The booklet didn't contain anything I didn't already know: But being by the same people who administer the test, it contained the same wording, it had similar situations from the test, it emphasized similar topics and situations. In a few minutes, it could easily make the difference between passing and failing.


Same approach with these "prepare for test XXX" books. It's a racket, but the special-purpose prep books work better at preparing you for the test than general knowledge (or general knowledge books) do.

by anonymous   2017-08-20

Rules of Sleep, Yield and Join

  • Sleeping is used to delay execution for a period of time, and no locks are released when a thread goes to sleep.

  • A sleeping thread is guaranteed to sleep for at least the time specified in the argument to the sleep() method (unless it's interrupted), but there is no guarantee as to when the newly awakened thread will actually return to running.

  • The sleep() method is a static method that sleeps the currently executing thread's state. One thread cannot tell another thread to sleep.

  • The setPriority() method is used on Thread objects to give threads a priority of between 1 (low) and 10 (high), although priorities are not guaranteed, and not all JVMs recognize 10 distinct priority levels—some levels may be treated as effectively equal.

  • If not explicitly set, a thread's priority will have the same priority as the priority of the thread that created it.

  • The yield() method may cause a running thread to back out if there are runnable threads of the same priority. There is no guarantee that this will happen, and there is no guarantee that when the thread backs out there will be a different thread selected to run. A thread might yield and then immediately reenter the running state.

  • The closest thing to a guarantee is that at any given time, when a thread is running it will usually not have a lower priority than any thread in the runnable state. If a low-priority thread is running when a high-priority thread enters runnable, the JVM will usually preempt the running low-priority thread and put the high-priority thread in.

  • When one thread calls the join() method of another thread, the currently running thread will wait until the thread it joins with has completed. Think of the join() method as saying, "Hey thread, I want to join on to the end of you. Let me know when you're done, so I can enter the runnable state."

by anonymous   2017-08-20

I thought protected fields and methods are visible to the children even if the latter are in a different package.

That's correct. The class itself has an access to the inherited protected members. But, what you're trying to do it to call the getHeight method on some Control reference. You're allowed to call it only on this instance!

For a better understanding, let me quote Kathy Sierra's SCJP Preparation Guide:

But what does it mean for a subclass-outside-the-package to have access to a superclass (parent) member? It means the subclass inherits the member. It does not, however, mean the subclass-outside-the-package can access the member using a reference to an instance of the superclass. In other words, protected = inheritance. The subclass can see the protected member only through inheritance.