junming zhang

Greenhorn
+ Follow
since Nov 03, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by junming zhang

1....
Object o;
For(int I=0;I<5;I++)
{
o = new Object();
}
2.........
For(int I=0;I<5;I++)
{
Object o = new Object();
}
3.....
Object o = null
For(int I=0;I<5;I++)
{
o = new Object();}
************************
I am confused about the three questions on how many unused objects can be eligeble for GC???
hope your help,and thank you in advance!!
best thanks for darryl,nain,maulin!!!
Q.
Consider the following classes:
public class Test {
public static void test() {
this.print();
}
public static void print() {
System.out.println("Test");
}
public static void main(String args []) {
test();
}
}
What is the result of compiling and running this class?
A.The string Test is printed to the standard out.
B.A runtime exception is raised stating that an object has not been created.
C.Nothing is printed to the standard output.
D.An exception is raised stating that the method test cannot be found.
E.An exception is raised stating that the variable this can only be used within an instance.
F.The class fails to compile stating that the variable this is undefined.
************
given answer is F.but I cann't know it clearly.if you think the answer is right,please explain it to me in detail.thanks for your reply!
Q.......
Select the valid primitive assignments of the following.
A.int i = 10;
char c = i;
B.float f;
long l = 100L;
f = l;
C.short s = 20;
char c = s;
D.byte b = 20;
char c = b;
E.short s1 = 10;
short s2 = 20;
short result = s1*s2;
give answer is a & b.
but i can't compile both in jdk1.3.1,i think the cast is necessary!!
if i am wrong ,pls correct me!!thanks!

i see,
Best thanks for FEI NG )
Q.At what stage in the following method does the object initially referenced by s becomes available for garbage collection. Select the one correct answer.

void method X() {
String r = new String("abc");
String s = new String("abc");
r = r+1; //1
r = null; //2
s = s + r; //3
} //4

A.Before statement labeled 1
B.Before statement labeled 2
C.Before statement labeled 3
D.Before statement labeled 4
E.Never.
given answer is D,but mine is E.
I know i am wrong,please crrect me!!
i am preparing for SCJP,i want to test me by mock exam.
please tell me where can i get it!
3x