What will be the output of the following Java code? [code] class booloperators { public static void main(String args[])

What will be the output of the following Java code?
Code:
    class booloperators {
        public static void main(String args[]) 
        {
            boolean var1 = true;
	    boolean var2 = false;
	    System.out.println((var1 & var2));
        } 
    }
A. 0
B. 1
C. true
D. false
 
Answer: d
Explanation: boolean '&' operator always returns true or false. var1 is defined true and var2 is defined false hence their '&' operator result is false.
output:
Code:
$ javac booloperators.java
$ java booloperators
false
 

Tìm kiếm

Back
Top