Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Michael Lin

Ranch Hand
+ Follow
since Dec 04, 2000
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 Michael Lin

I am preparing the SJCD from Brisbane, QLD
maybe we have some chances for help.
follow the link provided by the javaranch, or have a search on the key words Mock exam.

Originally posted by ashish gode:
Dear Michael Lin,
Great score, All the best for the future. I am giving JCP next WEEK. Do you know any materials online which could help me.

21 years ago
refer to the RHE book, in the charpter about Inner class.
it has good explaination.
21 years ago
Last Friday, I sat the sjcp and passed.
The questions are not so hard and tricky, but be careful and be focused on the objective outline.
Inner class and Thread are the most difficult ones.
Pay attention to the "constructor arguments" for anonymous class.
and Lock mechanism for Threads in synchronization.
you won't have much code, but you need to be very understanding of the theory and application.
And last I am not satisfied with the GUI of the real exam, which is different from most Mock exams, so you got to be flexible and quick in viewing.
The javaranch are talking more deeper and harder than the real exam, which is both good for the exam and your future job, that is the destination for all the certificates by ourselves, isn't it?
Best luck for all,
Michae Y. Lin
21 years ago
Thanks, Jane!
but my question is: why can't I use the interrupt() as in my example code???

Originally posted by Jane Griscti:
Hi Michael,
The answer is E ... there is NO WAY to pass control to a specific thread; <code>notifyAll()</code> alerts all the related waiting threads and then they compete for the lock.
Hope that helps.
[This message has been edited by Jane Griscti (edited January 14, 2001).]

42. There are 20 threads are waiting in the waiting pool with same priority, how can you invoke 15th thread from the waiting pool?.
A) By calling resume() method
B) By calling interrupt() method
C) Calling call() method
D) By calling notify(15) method on the thread instance
E) None of the above
//I think the answer can be B.
Can someone make it sure for me??
as I provide a code as following:
class Th extends Thread{
String na="";
Th(String name) { super(name); }

public void run() {
} // method run

public void countFrom1To100(){

System.out.println("Th start waiting: ");
try { na.wait();
}catch (InterruptedException e){
System.out.println("interrupted... ");

System.out.println("th finish. ");

} // method called by run

public static void main(final String args[]) {

Th th= new Th("worker");
try { sleep(2000);
}catch (InterruptedException e){}
th.interrupt(); //wake up the waiting thread!!!

System.out.println("main done: " );
} // class CounterHandler
//there is problem with this code, I can not fix it.
//can someone please help to explain it? Thanks!!
public class TransientWriter implements Externalizable

private transient String s = "Hope I can ever be persistant!";
public void writeExternal(ObjectOutput oOut) throws IOException

public void readExternal(ObjectInput oIn) throws IOException,
public String toString()
return s;
class K
public static void main(String args[]) throws IOException, ClassNotFoundException
TransientWriter tw = new TransientWriter();
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tw.out"));
ObjectInputStream in = new ObjectInputStream(new FileInputStream("tw.out"));
TransientWriter tw2 = (TransientWriter) in.readObject();
Question 78.
If a Runtime Exception is thrown in the finalize method -

1.The running application crashes.
2.The exception is simply ignored and the object is garbage collected.
3.The exception is simply ignored, but the object is not garbage collected.
4.The Exception causes the JVM to crash.

the answer is 2,
but I think should be 3, reading from the api.
can someone please correct this??
can anyone explain the following strange result??
class Base {
int i;
Base() {add(1);}
void add(int v) {i += v;}
void print() {System.out.println(i);}
class Extension extends Base {
Extension() {add(2);}
void add(int v) {
i += v*2;
public class Arg {
public static void main(String args[]) {
bogo(new Extension());
static void bogo(Base b) {

please try the following code:
public class Arg {
public static void main(String args[]) {
int x = 10, y;
if(x < 10) y = 1;<br /> if(x >= 10) y = 8; //line 1
//else y = 8; //line 2
System.out.println("y is " + y);
the code will give compile error, but if you use the line2 instead of line 1 it works fine.
Can someone explain to me why and how this happen,
Question 23.

A Button Object is created in a valid java code as below and run on two different platforms.

Buttonb = new Button("Hello");
Font f = new Font("sanssarif",Font.plain,12);

Select the following statement(s) that best describe Button object's nature on different platforms?

A.Button will be of the same size on both platforms as
SansSarif is a standard fixed width font.

B.If both platforms have identical 14-point Sanssarif font
then Button will be of same size on both platforms.

C.Button will be of same size on both platforms if both
platforms have same decoratioins.

D.We cannot guarentee Button will be of same size
on both platforms.

//can somebody explain which answer is correct?
//I am wondering after viewing the class Graphics's api, all the methods are abstract, and even the Graphics itself is abstract,
then how can we use those methods as nomorally, where are they get implemented??
an example is as follow, can anyone explain to me??

import java.applet.*;
import java.awt.*;
public class Arg extends Applet{
public void paint(Graphics g){
g.setColor(; //all abstract methods??
g.fillRect(0,0, 300, 200);
g.drawString("hi", 100, 50);

public static void main(String args[]) {

short c = 10;
int i = 20;
c += i;
System.out.println("not: " + c );


21 years ago
One of the Mock Exam says:
"Object class is not immutable"
I think it's wrong, there are no methods to change the state of an Object instance.
The Math class is not immutable as it is not allowed to instantiate an object at all.
I think it is correct.
Can anybody explain to correct me?
Is it reallly true that now the passing score is 61% or 71&??
I found the operator oder is different between bit shift and bitwise:
what is the order for:
8 | 9 & 10 ^ 11
and what is:
int x= 8 >> 9 <<< 10 >> 11
and what is:
boolean y==true==false==true;
can anybody please explain to me?