Anon Ning

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

Recent posts by Anon Ning

Hi all:
I just begin to study Servlet and JSP.I spent a lot of time to install tomcat,but it still doesn't work.When I click startup, it appears "Out of environment space Out of environment space Out of environment space Unable to determine the value of CATALINA_HOME". I don't know why? Please help me because I have spent too much time on it.In addition, mu computer's os is Windows Me.
Thanks!
Anon
04/15/01
23 years ago
hi all:
See the following question:
Which of the following is true regarding main Thread?
A) It is the thread from which other "child" threads will be
spawned.
B) It must be the last thread to finish execution. When the main
thread stops, the program terminates.
C) It has the highest priority.
D) main is not a thread.
The answer is A) and B)
I understand A),but but I was confused about B). I think the main thread can finish, but the program will keep running until all the user threads which are spawned from the main thread are done.
Please help me. Thanks!
I think there are two objects were created. One is sb and another is "abcde".Am I right?
Thanks Michael! I got it.
hi all:
See this code:
class Process {
byte b=127;

Process() {
this.methodA();
}

void methodA() {
System.out.println("Value of b is = " +b );
}

public static void main(String [] args) {
Processor p = new Processor();
}
}

class Processor extends Process {
byte b=126;

Processor() {
System.out.println("Value of b* = " + b);
}

void methodA() {
System.out.println("Value of b** = " + this.b);
}
}
The output is :
Value of b**= 0 //(1)
Value of b*= 126
I was confused why line (1) is 0 rather than 126?
Please help me.Thanks!
hi all:
I will take SCJP2 exam at the end of this month.I want to buy some mock exams.Please tell me which one is better, JCertify 4.0 or J@Whiz?
Thanks.
hi all:
I will take SCJP2 exam at the end of this month.I want to buy some mock exams.Please tell me which one is the best, JCertify 4.0, or jqplus, orJ@Whiz?
Thanks.
23 years ago
hi all:
See the following question:
Which modifiers would be valid in the declaration of a main() method so that the class can be run from command line?
a) native
b) protected
c) public
d) final
e) abstract
The answer is a),c),and d).
I don,t know why choose a)? Why b) is not correct?
Please help me!
In addition,how about JCertify mock exam? Is it worth to buy?
Thanks!
Thanks Philosopher.I got it. When I change the abovement code into the following code , I get the value 10.
public class TestClass implements Runnable
{
int x = 5;
public void run()
{
this.x = 10;
}
public static void main(String[] args)
{
TestClass tc = new TestClass();
new Thread(tc).start(); // 1
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
System.out.println(tc.x);
}
}
The output is 10.
That means when the current thread(main thread) is sleeping,the another thread which was ready to run is executed. So the value is changed to 10.Therefore,the correct answer is e). Is that right?
hi all:
See this code:
public class TestClass implements Runnable
{
int x = 5;
public void run()
{
this.x = 10;
}
public static void main(String[] args)
{
TestClass tc = new TestClass();
new Thread(tc).start(); // 1
System.out.println(tc.x);
}
}

what will it print when run?
a) 5
b) 10
c) It will not compile
d) Exception at runtime
e) The output can not be determined
I choosed a)5. However, the correct answer is: e) The output can not be determined. I don't know why. I think according to Java's "Pass by Value" theory,it always print 5.
Please help me.
Thanks.
Wonderful explanation! I got it.
Thanks Jyotsna!
Thanks Jyotsna.
But how about the following code:
public class TestClass10
{
public static void main(String args[ ] )
{
int i = 1;
int[] iArr = {1};
incr(i) ;
incr(iArr) ;
System.out.println( "i = " + i + " iArr[0] = " + iArr[0]) ;
}
public static void incr(int n ) { n++ ; }
public static void incr(int[ ] n ) { n [ 0 ]++ ; }
}
The output is :
i=1 iArr[0]=2
I think the output should be: i=1 iArr[0]=1
why iArr[0] is 2?
Please expalin me .Thanks!
hi all:
See this code below:
public class TestClass17
{
static String str="Hello World";
public static void changeIt(String s)
{
s = "Good bye world";
}
public static void main(String[] args)
{
changeIt(str);
System.out.println(str);
}
}
The output is :Hello World
Why the output is "Hello World"? I think 'str' is a reference and after it was passed to method changeIt(String s),its value will be changed to "Good bye world".So the output should be: Good bye world. But it isn't.I was confused .Please help me.
Thanks!
Thanks Christopher.
But I can not understand this sentence in your explain
"no copy of the array is constructed."
Can you explain it further?
In addition,see the following code:
public class TestClass17
{
static String str="Hello World";
public static void changeIt(String s)
{
s = "Good bye world";
}
public static void main(String[] args)
{
changeIt(str);
System.out.println(str);
}
}
The output is : Hello World
Why not "Good bye world"? Does it pass a copy of reference "str"?
Please explain it.Thanks.
hi all;
Look the following code:
public class TestClass10
{
public static void main(String args[ ] )
{
int i = 1;
int[] iArr = {1};

incr(i) ;
incr(iArr) ;
System.out.println( "i = " + i + " iArr[0] = " + iArr[0]) ;
}
public static void incr(int n ) { n++ ; }
public static void incr(int[ ] n ) { n [ 0 ]++ ; }
}
The output is :
i=1 iArr[0]=2
I think the output should be: i=1 iArr[0]=1
why iArr[0] is 2?
I feel confused about Pass by Value.Can someone explain this concept to me?
Thanks!