Operators in Java Exercise I


Ques 1 Operator


What is the output of the following code ?

class Test
{
      public static void main(String[] args){
           int a=10;
           int b=a;
           a++;
           int c=b;
           c++;
           System.out.println(b);
      }
}

  a) 10
  b) 11
  c) 12
  d) 13


a is the correct option




Ques 2 Operator


What is the result of the following expression: 5 / 2.0?
  a) 2.5
  b) 2
  c) 2.0
  d) 2.2


a is the correct option




Ques 3 Operator


Which operator is used to perform logical negation in Java?
  a) !
  b) ~
  c) -
  d) ++


a is the correct option