What is the output of this program?
class booloperators {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
System.out.println((var2 & var2));
}
}
class booloperators {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
System.out.println((var2 & var2));
}
}
Solution:
boolean ‘&’ operator always returns true or false.
var1 is defined true and var2 is defined false hence their ‘&’ operator result is false.
output:
$ javac booloperators.java
$ java booloperators
false
boolean ‘&’ operator always returns true or false.
var1 is defined true and var2 is defined false hence their ‘&’ operator result is false.
output:
$ javac booloperators.java
$ java booloperators
false