201k views
1 vote
int x = 3; int y = x / 2; if ( x > 0 && y > 2 ) System.out.println( "A" ); else if ( x > 0 && y > 1 ) System.out.println( "B" ); else if ( x > 0 && y > 0 ) System.out.println( "C" ); else if ( x == 3 ) System.out.println( "D" ); else System.out.println( "E" );

User Moraei
by
4.5k points

1 Answer

1 vote

Answer:

B

Step-by-step explanation:

  • Given are if else conditions. It is the rule that if any condition matches with the given statement, no other conditions are checked or dealt.
  • As x =3 and y = x/3 (1.5) so the first condition in if block will not match but the second in else if matches the condition as ( x > 0 && y > 1 ). As this statement says to print B if condition is true So B will be printed on to the screen.
  • Now no more statements are checked weather they match or not.

I hope it will help you!

User SantiagoIT
by
5.5k points