Computer Science, asked by sindhuri139, 10 months ago

Public class if2 { static boolean b1, b2; public static void main(string [] args) { int x = 0; if ( !B1 ) { if ( !B2 ) { b1 = true; x++; if ( 5 > 6 ) { x++; } if ( !B1 ) x = x + 10; else if ( b2 = true ) x = x + 100; else if ( b1 | b2 ) x = x + 1000; } } system.Out.Println(x); } }

Answers

Answered by gauravy
2

Answer:

101

Explanation:

As instance variables, b1 and b2 are initialized to false. The if tests on lines 7 and 9 are successful so b1 is set to true and x is incremented. The next if test to succeed is on line 19 (note that the code is not testing to see if b2 is true, it is setting b2 to be true). Since line 19 was successful, subsequent else-if's (line 21) will be skipped.

Similar questions