Home / CSE MCQs / JAVA MCQs :: Operators - Java

CSE MCQs :: JAVA MCQs

  1. Which of the following can be operands of arithmetic operators?
  2. A.
    Numeric
    B.
    Boolean
    C.
    Characters
    D.
    Both Boolean & Characters

    View Answer

    Workspace

    Discuss Discuss in Forum


  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. A.
    1, 2 & 3
    B.
    1 & 4
    C.
    1, 2, 3 & 4
    D.
    3 & 2

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Decrement operator, “, decreases value of variable by what number?
  6. A.
    1
    B.
    2
    C.
    3
    D.
    4

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of these statements are incorrect?
  8. A.
    Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms.
    B.
    Assignment operators run faster than their equivalent long forms.
    C.
    Assignment operators can be used only with numeric and character data type.
    D.
    None

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of this program?
    class increment {
    public static void main(String args[])
    {
    double var1 = 1 + 5; 
    double var2 = var1 / 4;
    int var3 = 1 + 5;
    int var4 = var3 / 4;
    System.out.print(var2 + " " + var4);
     
    }
  10. A.

    1 1

    B.

    0 1

    C.

    1.5 1

    D.

    1.5 1.0

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of this program?
    class Modulus {
    public static void main(String args[]) 
    {    
    double a = 25.64;
    int  b = 25;
    a = a % 10;
    b = b % 10;
    System.out.println(a + " "  + b);
    }
  12. A.

    5.640000000000001 5

    B.

    5.640000000000001 5.0

    C.

    5 5

    D.

    5 5.640000000000001

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this program?
    class increment {
    public static void main(String args[]) 
    {        
    int g = 3;
    System.out.print(++g * 8);
    }
  14. A.
    25
    B.
    24
    C.
    32
    D.
    33

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What is the output of this program?
    class Output {
    public static void main(String args[]) 
    {    
    int x , y;
    x = 10;
    x++;
    --x;
    y = x++;
    System.out.println(x + " " + y);
    }
  16. A.

    11 11

    B.

    10 10

    C.

    11 10

    D.

    10 11

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which operator is used to invert all the digits in binary representation of a number?
  18. A.
    ~
    B.
    >>>
    C.
    ^

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?
  20. A.
    1
    B.
    32
    C.
    33
    D.
    31

    View Answer

    Workspace

    Discuss Discuss in Forum