Ray Chang

Greenhorn
+ Follow
since Sep 10, 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 Ray Chang

Can anybody tell me how to point to existing style sheet on the web.
Thank you
Thanks everybody here.
The exam is not very difficult but it's tricky, I think. So concentration is very important.
Good luck for javaranch.com , hopeful the website will be kept open forever.
Good luck for everybody.
19 years ago
Below two declaration of native methods, which one is correct?
1. public void native m();
2. public native void m();
I recalled that the order of modifiers is not a problem. how about the order of modifiers and "void"? Does void must follows modifiers in the statments?
Can somebody explain the difference of these two? I went throgh JLS, but didn't catch the point.
By the way, does runtimeException should be catched?
I'm confused. Does 4<<=2 give 16 as a result? Can anybody expain how this kind of things work?
<<=, |=, >>=...
Thank you.
Thank you.
Your mock exams are very helpful.
Below is included an answer of Marcus Green's Mock Exam 3. Can anybody tell me whether you met this kind of thing in the exam?thx
----------
You may get questions in the exam that have no apparently correct answer. If you are absolutely sure this is the case, do not check any of the options.
---------
Thank you. I know the code below will give an output 0.
int i=0;
System.out.println(i++);
But I guess it's different when the code is like below:
int i=0;
i=i++;
System.out.println(i);
In my understanding, immediately after the statement i=i++; is excuted, i is 0. But then i is incremented after that and is 1. then the System.out.println(i); excuted and the output is 1. If I was wrong, when will i be incremented at this kind of statements?Thanks again
Question 54)
What will happen when you attempt to compile and run the following code?
public class Inc{
public static void main(String argv[]){
Inc inc = new Inc();
int i =0;
inc.fermin(i);
i = i++;
System.out.println(i);
}
void fermin(int i){
i++;
}
}
1) Compile time error
2) Output of 2
3) Output of 1
4) Output of 0
the given answer is 4. I'm confused. I know that if the statement is System.out.println(i++); then the output will be the current i, say 0. But is there any difference between the statement System.out.println(i++); &
i = i++;
System.out.println(i); ?
Can anybody give me a clear expanation?Thank you
31. Consider the code below:
void myMethod()
{ try
{
fragile();
}
catch( NullPointerException npex )
{
System.out.println( "NullPointerException thrown " );
}
catch( Exception ex )
{
System.out.println( "Exception thrown " );
}
finally
{
System.out.println( "Done with exceptions " );
}
System.out.println( "myMethod is done" );
}
What is printed to standard output if fragile() throws an IllegalArgumentException?
a) "NullPointerException thrown"
b) "Exception thrown"
c) "Done with exceptions"
d) "myMethod is done"
e) Nothing is printed
Is this question, I thought the exception throwed by fragile() was catched by the 2nd catch statement and then the finally statement executed.And then it jumps out of myMethod()
So my answer was b & c.
But the answer in the correct answer was b & c & d. What'd the problem?
I know the s.concat("java");
gives no change to s.
but does
String s="Hello" + "java";
give us the same as
String s="Hellojava" ?
11. The statement ...
String s = "Hello" + "Java";
yields the same value for s as ...
String s = "Hello";
String s2= "Java";
s.concat( s2 );
True
False

I thought + here is overloaded to concatenate the strings, but I thought it's a easier way for concat(). so my answer was true. but the correct answer is false. Is it correct?