andy lau

Ranch Hand
+ Follow
since Apr 08, 2002
Merit badge: grant badges
For More
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 andy lau

but how do you know whether there is a variable to receive the returned oa[0]?
assume there is no variable to do this,then the object must be GC.
Given:
public class andy {
public object amy () {
object o = new float (3.1415F);
object [] oa = new object[1];
oa[0]= o;
o = null;
return oa[0];
}
}
When is the float object created in line 3, eligible for garbage collection?
A. Just after line 5
B. Just after line 6
C. Just after line 7 (that is, as the method returns)
D. Never in this method
i think c is the right answer,because althought the oa[0] is returned by the method ,but there is no variable to receive or hold the object reference ,so when the method returns the object is eligible for GC.
if the two two-dimentional arrays do not have equal number of elements in each dimention,how does the assigment happen?
thanks.
maybe i havent expressed clearly. what i mean is that:
how can i determine which checked exception in the catch declaration will cause compiler fail and which not?
thank you all the same!
how can i determine which checked exception will cause compiler fail and which not?
but how can i determine which checked exception will cause compiler fail and which not?
If there�s no code in try block that may throw exceptions specified in the catch blocks,compiler will produce an error. (This is not the case for super-class Exception)
true or false?
do you mean that no matter when and where i creat an object using the ''new'' keyword will cause the toString() method of that object to be executed automaticly?
thanks!
what does the ''thread-safe'' mean? is there any link to this topic?
i dont understand why you say D is still wrong ? can you explain more ?
thanks a lot!
class C {
public static void main(String arg[]) {
System.out.println("A"+new C());
}
public String toString() {
System.out.print("B");
return "C";
}
}
The output is :BAC
can you tell me why?
The code is as follows(from the mock exam JOP):

Which statement is true?
A.The andy class is fully encapsulated.
B.The diameter of a given andy is guaranteed to be twice its radius.
C.Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D.The radius of a MyCircle object can be set without affecting its diameter.
I think the answer should contain D. But i am not sure whether the C is right. can you explain the answer C ?
Thanks a lot!
i think the yield() method will cause the current executing thread to stop!
At least,the executing Thread will stop to ''look outside'' and to find whether there is any Thread with the same or higher priority. so i think the yield() method will definitly cause the current executing thread to stop!
am i right?
hooo! i am so careless!!
thank you very very much!
Corey McGlone :
you said :Actually, if you look closely at the answers, B and C can't possible be true - those cases could never happen.
Can you explain why? thanks a lot!