Java Quiz 6 : Operators

    Welcome to your Java Quiz 6 : Operators

    1. Which of the following can be operands of arithmetic operators?
    2. Modulus operator, %, can be applied to which of these?
    3. With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
     1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1;
    4. Decrement operator, −−, decreases the value of variable by what number?
    5. Which of these statements are incorrect?
    6. What will be the output of the following Java program?
    1.  class increment 
    2.  {
    3.  public static void main(String args[])
    4.  {
    5.  double var1 = 1 + 5; 
    6.  double var2 = var1 / 4;
    7.  int var3 = 1 + 5;
    8.  int var4 = var3 / 4;
    9.  System.out.print(var2 + " " + var4);
    10.  
    11.  } 
    12.  }
    7. What will be the output of the following Java program?
    1.  class Modulus 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  double a = 25.64;
    6.  int b = 25;
    7.  a = a % 10;
    8.  b = b % 10;
    9.  System.out.println(a + " " + b);
    10.  } 
    11.  }
    8. What will be the output of the following Java program?
    1.  class increment 
    2.  {
    3.  public static void main(String args[]) 
    4.  { 
    5.  int g = 3;
    6.  System.out.print(++g * 8);
    7.  } 
    8.  }
    9. Can 8 byte long data type be automatically type cast to 4 byte float data type?
    10. 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;
    8.  int d;
    9.  c = ++b;
    10.  d = a++;
    11.  c++;
    12.  b++;
    13.  ++a;
    14.  System.out.println(a + " " + b + " " + c);
    15.  } 
    16.  }
    11. Which of these is not a bitwise operator?
    12. Which operator is used to invert all the digits in a binary representation of a number?
    13. On applying Left shift operator, <<, on integer bits are lost one they are shifted past which position bit?
    14. Which right shift operator preserves the sign of the value?
    15. Which of these statements are incorrect?