about static variable

anybody can tell why the answer is B,? i think it should be D.

thanks

1. public class test (

2. private static int j = 0;

3.

4. private static boolean methodB(int k) (

5. j += k;

6. return true;

6. )

7.

8. public static void methodA(int i) {

9. boolean b:

10. b = i < 10 | methodB (4);

11. b = i < 10 || methodB (8);

12. )

13.

14. public static void main (String args[] } (

15. methodA (0);

16. system.out.printIn(j);

17. )

18. )

What is the result?

A. The program prints ?br>B. The program prints ?br>C. The program prints ?br>D. The program prints ?2?br>E. The code does not complete.

Answer: B

[747 byte] By [javagirla] at [2007-11-27 9:00:00]
# 1
Because the boolean OR (||) in java short-circuits. since the first part of this expression: b = i < 10 || methodB (8);is true, the second part (the call to methodB() is never excecuted.~Tim(the boolean OR (|) is the non-short-circuiting version)
SomeoneElsea at 2007-7-12 21:28:11 > top of Java-index,Java Essentials,Training...
# 2
thank you very much .the problem has been trouble me whole day now i understand thanks again
javagirla at 2007-7-12 21:28:11 > top of Java-index,Java Essentials,Training...