Answer to Question #3569 in Java | JSP | JSF for Y mukundareddy
(4) Write a program to perform all the logical operators on the following two variables, a= 10,b=5?
1
2012-03-16T09:19:32-0400
There are four logical operators - &, &&, | and | |.
| | And && can only be used in logical expressions.
public class Main {
public static void main(String[] args) {
boolean a = true, b = false;
int i = 10, j = 5;
System.out.println("a & b: " + (a&b));
System.out.println("a | b: " + (a|b));
System.out.println("a && b: " + (a&&b));
System.out.println("a || b: " + (a||b));
System.out.println("i & j: " + (i&j));
System.out.println("i | j: " + (i|j));
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment