Yingtao Jiang

Greenhorn
+ Follow
since Nov 05, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Yingtao Jiang

Hi,there,

I bought four Sun electronic Vouchers last year on ebay, but now I only used two. Still have two spare, and I do not have enough time to take the other exams now.

Please see: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&ssPageName=ADME:L:LCA:US:31&item=7006799294

Those vouchers seems are vouchers sun give to their emploees but can be used by anyone. But you must register the test before end of May 2006.

If you are interested, please let me know.
Hi,there,
I have two spare Sun Exam electronic vouchers. I listed one on ebay for sell, if you are interested, please check it out. thanks.

http://cgi.ebay.com/Sun-exam-
[ February 07, 2006: Message edited by: Yingtao Jiang ]
Hi,

The answer is E, but I thought it should be D. Right?

Thanks
That binary pattern IS -1.
Because it is 2's complement. As the sign bit(the left most) is 1, so it is a negative number, in order to calculate its absolute value, you can do the following:
bitwise negation first, then plus 1.
So the all 1 pattern will become 000000...01.

Joe Sanowitz
pls tell the reason why floating value is chaning on casting to double even when it can hold the interger.max value... ?


Yes, float value can "hold" the integer.max value. Which only means the integer.max value fall into the "range" of the number a float can represents. BUT: It is impossible for float to PRECISELY represents all the numbers fall within its range. That is simply because there is infinite float numbers fall within a un-empty range and the bit-depth of float is limited.
I passed with 90% today.
Not very happy though. Do not know why I got a 66% in Garbage collection and a 66% in Collection framework.
I though I know the Garbage collection stuff very well :<.

Suggestions for the other test taker:
The most important thing is carefullness at test time.
K&B book is very good, if you do not have a lot of time, just use that book to prepare your SCJP exam. The Two-minutes drill part is especially helpful. I read the book for three days, and took the mock exams comes with it for three times. I learn a lot from the book. Even though I "though" I was an experienced Java programmer, I fail the mock exam the first time I tried it.
[ April 15, 2005: Message edited by: Yingtao Jiang ]
15 years ago
Hi, Simon,

I think you make a mistake here.

If a thread is accessing a method, which is marked as synchronized, the thread will need the lock of the object that is represented by the class the method is defined in. Ergo, no other thread would be able to access any other synchronized methods in the same class.



This is true only for static method. For instance method, the lock is on the receiver object. As long as the reciever object is different, two threads can concurrently enter synchronized method that operate on different object of the same class.

once one of threads enters one of the synchronized methods in the ZZ class, the other thread can't enter the other method until it has finished...

Please see the modified example of yours below.


From the running result, you can see that, thread-0 and thread-1 can concurrently run aMethod() and bMethod(). As sleep() method do not give up lock, this example demonstrate that the two thread keep two different lock, which belongs to two instance of the same class.

Hope I made my point clear.

Are there any exceptions that do not inherit from Exception?


Of course, you can define a myException Calss which extends directly from Throwable class. And throw a myException anywhere you think appropriate in your code.
Hi, Paulo,

Inside the Matrix constructor,method1 of Matrix is called
it prints "You are inside method 1 of Matrix"



This statement is wrong... unless the "method1()" in Matrix have an access modifier "private".

The method inside Matrix called is "this.method1()". If the Matrix class defined a private method1(), then, the method call will be binded at compile time. Otherwise(not a private--protected, default,public-- means possibly be overriden in subclass), the method call is dynamically binded. It will call the method1 of "this" object--i.e. the receiver object (in this case, the Revolution object). If the runtime can not find a method1() in the receiver object, then it will climb up the inherientance tree untill it find one or declare an compile error.

Also, IMO, it NEARLY always a design error/flaw to call non-private method inside a constructor. As the called method could be override, and the behavior is undefined (out of your control). How could you use that kind of method to "initialize" the state of your object? The only exception of this kind of use mightbe in designing a hooking class in a framework intented to be override, and the document clearly specified the intended behavior of the method to be overriden by the subclass.

Hope my explaination helps.

I think it should be "copy of a reference" that gets passed as a parameter.



You are right,but that exactly what "pass by value" means. As in java, there is not "object" variable, the only way you can access an object is through the "reference variable" associate with it. So the only thing you can "pass to" a method is a reference variable (of course, primitive type too), and it is "passed by value"-- i.e. a copy of the original reference variable is taken and could be modified by the method body, but not the original one.
Hi,Kelvin,
The problem lays in the 3 statement:
str += "ball"; // 3
Here let write the statement in another way.
str=str+"ball";
The right side evaluate to a "baseball" object, which is a new object and has nothing to do with
the "ball" object the str reference used to refer to.
Then the str reference bind to the new object "baseball".And at this time, str and s are bind to different objects(s still bind to "ball").
Hope this will help.