Hi All,
can you please help me in understanding this question? This is from K&B Chapter3 Q 12.
1. class BoolArray {
2. boolean [] b = new boolean[3];
3. int count = 0;
4.
5. void set(boolean [] x, int i) {
6. x[i] = true;
7. ++count;
8. }
9.
10. public static void main(
String [] args) {
11. BoolArray ba = new BoolArray();
12. ba.set(ba.b, 0);
13. ba.set(ba.b, 2);
14. ba.test();
15. }
16.
17. void
test() {
18. if ( b[0] && b[1] | b[2] )
19. count++;
20. if ( b[1] && b[(++count - 2)] )
21. count += 7;
22. System.out.println("count = " + count);
23. }
24. }
what is the result?
A. count = 0
B. count = 2
C. count = 3
D. count = 4
E. count = 10
F. count = 11
Here count is not static variable. How it is incrementing for each call to set() method?