Operator in Java MCQs Exercise II

Ques 1 Operator


What is the output of the following Java Code?


public class divide{
 public static void main(String[] args){
 float ans1=5.3f;
 float ans2=2.3f;
 float res= ans1 %ans2;
 System.out.println(res);
}
} 

A 0.7000003
B 0.7
C Runtime Error
D Error because % operator cannot be applied on float data range

Ques 2 Operator


What is the output of the following Java Code?


public class operator{
 public static void main(String[]args){ 
    boolean flag=false;
    if(flag = true){
    System.out.println("Hello");
    }
    if(flag = false){
    System.out.println("World");
    }
 }
}

A Hello
B World
C No output
D Error