Sail E0 Webinar
Question


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));
}
}
Options:
A .  0
B .  1
C .  true
D .  false
Answer: Option D

 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



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers