Java OCA OCP Practice Question 191

Question

Given:

3. public class Main {
4.   public static void main(String[] args) {
5.     int mask = 0;
6.     int count = 0;
7.     if( ((5<7) || (++count < 10)) | mask++ < 10 )   mask = mask + 1;
8.     if(  (6 > 8) ^ false)                           mask = mask + 10;
9.     if( !(mask > 1) && ++count > 1)                 mask = mask + 100;
10.     System.out.println(mask + " " + count);
11.   }/*from  w  ww .j av a2  s.c  om*/
12. }

Which two are true about the value of mask and the value of count at line 10?

Choose two.

  • A. mask is 0
  • B. mask is 1
  • C. mask is 2
  • D. mask is 10
  • E. mask is greater than 10
  • F. count is 0
  • G. count is greater than 0


C and F are correct.

Note

At line 7 the || keeps count from being incremented, but the | allows mask to be incremented.

At line 8 the ^ returns true only if exactly one operand is true.

At line 9 mask is 2 and the && keeps count from being incremented.




PreviousNext

Related