Java Quiz 7 : Operators II

    Welcome to your Java Quiz 7 : Operators II

    1. What will be the output of the following Java program?
    1.  class bitwise_operator 
    2.  {
    3.  public static void main(String args[])
    4.  {
    5.  int var1 = 42;
    6.  int var2 = ~var1;
    7.  System.out.print(var1 + " " + var2); 
    8.  } 
    9.  }
    2. What will be the output of the following Java program?
    1.  class bitwise_operator 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int a = 3;
    6.  int b = 6;
    7.  int c = a | b;
    8.  int d = a & b; 
    9.  System.out.println(c + " " + d);
    10.  } 
    11.  }
    3. What will be the output of the following Java program?
    1.  class leftshift_operator 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  byte x = 64;
    6.  int i;
    7.  byte y; 
    8.  i = x << 2;
    9.  y = (byte) (x << 2)
    10.  System.out.print(i + " " + y);
    11.  } 
    12.  }
    4. What will be the output of the following Java program?
    1.  class rightshift_operator 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int x; 
    6.  x = 10;
    7.  x = x >> 1;
    8.  System.out.println(x);
    9.  } 
    10.  }
    5. What will be the output of the following Java program?
    1.  class Output 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int a = 1;
    6.  int b = 2;
    7.  int c = 3;
    8.  a |= 4;
    9.  b >>= 1;
    10.  c <<= 1;
    11.  a ^= c;
    12.  System.out.println(a + " " + b + " " + c);
    13.  } 
    14.  }
    6. What is the output of relational operators?
    7. Which of these is returned by “greater than”, “less than” and “equal to” operators?
    8. Which of the following operators can operate on a boolean variable?
     1. && 2. == 3. ?: 4. +=
    9. Which of these operators can skip evaluating right hand operand?
    10. Which of these statements is correct?
    11. What will be the output of the following Java code?
    1.  class Relational_operator 
    2.  {
    3.  public static void main(String args[])
    4.  {
    5.  int var1 = 5; 
    6.  int var2 = 6;
    7.  System.out.print(var1 > var2);
    8.  } 
    9.  }
    12. What will be the output of the following Java code?
    1.  class bool_operator 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  boolean a = true;
    6.  boolean b = !true;
    7.  boolean c = a | b;
    8.  boolean d = a & b;
    9.  boolean e = d ? b : c;
    10.  System.out.println(d + " " + e);
    11.  } 
    12.  }
    13. What will be the output of the following Java code?
    1.  class ternary_operator 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int x = 3;
    6.  int y = ~ x;
    7.  int z;
    8.  z = x > y ? x : y;
    9.  System.out.print(z);
    10.  } 
    11.  }
    14. What will be the output of the following Java code?
    1.  class Output 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int x , y = 1;
    6.  x = 10;
    7.  if (x != 10 && x / 0 == 0)
    8.  System.out.println(y);
    9.  else
    10.  System.out.println(++y);
    11.  } 
    12.  }
    15. What will be the output of the following Java code?10. What will be the output of the following Java code?