huiying li

Ranch Hand
+ Follow
since Feb 12, 2001
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 huiying li

y is an instance variable, it is initialized after 'this(y)' statement, which creates an error. Change it to static variable will solve the problem.

[This message has been edited by huiying li (edited October 14, 2001).]

If a thread does not specify a priority, then it is inherited from its parent thread, which may have set a different priority than Thread.NORMAL_PRIORITY when it is created.

[This message has been edited by huiying li (edited March 24, 2001).]
Here is a quote from the API on Thread class
"When code running in some thread creates a new Thread object, the new thread has its priority initially set equal to the priority of the creating thread."
This reference should be useful:
15.13.2 Examples: Array Access Evaluation Order
a[a[b]] = a[b] = b = 2; is evaluated as follows
0) The left-hand operand of a binary operator is evaluated first
1) a[a[b]] evaluates to a[0]
2) a[b] evaluates to a[0]
3) assignment is evaluated performed right to left
4) b = 2 assigns 2 to b and returns 2 to a[b]
5) a[0] = 2 assigns 2 to a[0] and returns 2 to a[a[b]]
6) a[0] = 2 assigns 2 to a[0] again and returns 2
No specific assignment is made to the other three array elements, so they still have the default int value of zero.
Therefore, a[0] = 2, a[1] = 0, a[2] = 0, a[3] = 0 are printed out.
Here is a simple example that shows that an instance of anonymous inner class can be created outside its outer class.
The class Outer has a method which returns an anonymous class object. This method is called in class Test41, and the print statement shows indeed an anonymous inner class object is created.

C:\JavaRanch>java Test41
I am an anonymous class object

[This message has been edited by huiying li (edited March 23, 2001).]
Hi Eric,
When I was preparing for the SCJP I used JQ+ as a study tool like this:
1) test one JQ+ test, it takes normally between one hour to one hour and half to finish each test
2) read the answers to each question very carefully, pay special attention to the ones I got wrong and the ones I guessed at the answer
3) go back to my Mughal book to re-read the chapters related to my weaker areas in the JQ+ test, and check with the API document and JLS for further clarifications.
You are correct and here is a quote from Java language specification.
"Positive zero and negative zero compare equal; thus the result of the expression 0.0==-0.0 is true and the result of 0.0>-0.0 is false. But other operations can distinguish positive and negative zero; for example, 1.0/0.0 has the value positive infinity, while the value of 1.0/-0.0 is negative infinity."
You should also read the API documentation for Double class method equal().
Hope this helps.

Originally posted by Ronnie Phelps:
Did any of you guys get questions that required you to know the order of precidence of operators? If so, do you think I should study order of precidence for purposes of the exam?

Yes, you definitely should especiall pre and post unary operators (++i, i--) and short circuit logical operators ( &&, | |).
23 years ago
JQ+ is a mock exam software, it is $20 and well worth it.
AWT questions are not hard, it tests your memory, either you know them or you don't. I remember getting four on the test.
One on LayoutManager, one on resizing behavior, two on AWT event handling.
Hope this helps.

[This message has been edited by huiying li (edited March 15, 2001).]
23 years ago
Just passed SCJP today.
To those who is going to take the test here are some tips:
1) Study thread really well, I got a question on join() so you need to know that too. It is the first section of the test, and the questions are not easy.
2) IO, stick with the exam objective, know the effects on the file system due to File, FileOutputStream constructors, and I got questions on DataOutputStream constructor also.
3) The questions on other sections are fairly easy, if you understand all the answers in JQ+.
4) Spend sometime on hexadecimal representation of numbers, I had a theoritical understanding, but panicked when I got a 32 bit int in hex format, and has to do bitwise operation on it. It cost me at least 10 minutes to get it right.
23 years ago
In general follow these steps in creating a frame
1) create the components and frame
2) chose a layout manager using setLayout()
3) add the components to the frame
4) size the frame and make it visible

I think you are right.
[This message has been edited by huiying li (edited March 14, 2001).]
Java source file can only have, at most, one public class, it must have the same name as the file name.
Either change one of the class to package access or put it in a separate file, the code should be fine.

C:\JavaRanch>java Test35
Hi there
The question was:
What methods have to be implemented by a class that says it implements I1 and I2 ?
The answer was:
There is no way that an method can declare an exception that satisfies both the methods.
As in my code, the class can declare no throws clause that will satisfy both interface method requirement.
Any thoughts?
Thanks for your replies, hopefully there won't be something ambiguous like this in the real test.