wei luo

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

Recent posts by wei luo

What will be output by the following line of code?
System.out.println(010|4);
1) 14
2) 0
3) 6
4) 12
The answer is 4). 010 is taken as an octal number. Why can't take it as a binary one?
Thanks to everyone. It is clear to me now.
Thanks, Torgny. By the way, how long does it take to arrive you?
I prepare to take SCJP in August or September. I just find that jchq.com says the expiration of the exam is 6 months while javacaps.com says the voucher is valid for one year. Which one is true? Does that mean I can take as many times as I like within that period without paying additionally? Based on the fact that I can make most of the mock exams about 60 to 70 percent correct, how hard should I work to clear the exam? Thank you for your advice.
Many thanks to everyone.
Oh, I tested it. If we use "threadname1.start(); threadname2.start(); System.out.println("...")", the order of output is not guaranteed. but the order of outputs of the two start() are relatively fixed. Is that true?
Hi, Dave:
I tested the code as you said. But I don't understand why "end of main" comes before the two "in run". I know it must be a simple question, but I haven't got it. Thanks.
Dave, in your example, do you mean we can create a class with a static array of integers from 1 to 13, initialize it in a static block, then in constructors we need only deal with the suits? Then, is instance initializer block still the same useful?
I still can't see why initializer blocks exist? Why not just initialize variables where they are declared or in the constructors?
So the following will compile, right?
a tempa = new a();
Runnable r = tempa;
I think "final Vector v;
public AllFinals()
{ v = new Vector();
}
will also work.
Hello, every helper:
I got another three problems in go4java. Would you please help?
1)1. class Q43
2. {
3. int y=1;
4. Q43()
5. {
6. this(y);
7. }
8. Q43(int x)
9. {
10. y=x++ + ++x;
11. }
12. public static void main(String [] args)
13. {
14. Q43 t = new Q43();
15. System.out.println(t.y);
16. }
17. }
The answer is "It will give you compile time error as you cannot reference y before super class constructor has been called". I don't understand why it has relation with super class.
I think it should compile correctly and print 4.
2) 1. public class Q45
2. {
4. static
5. {
6. System.out.print("Java".startsWith(""));
7. }
8. static void processorB()
9. {
10. System.out.println(" is a boolean Operator.");
11. }
12. static Q45 processorA()
13. {
14. Q45 q=null;
15. if (("java").startsWith("null"))
16. return q;
17. else
18. return null;
19. }
20. public static void main(String[] args)
21. {
22. processorA().processorB();
23. }
24. }
The answer is "Program will compile correctly and print true is a boolean operator when executed. ". Why is there no NullPointerException? Is it because processorB() is static? If so , then we can use null object of a class to invoke its static method at any time?
3)Why don't we need to throw Exception before catching it, while if "class Except extends Exception{}" and we want to catch Except, then we must first throws it?

4) Anybody knows any site stating about initializer block and static initializer block? I am new to that.
Thanks, everyone. Have a good day.