Answer to Question #3569 in Java | JSP | JSF for Y mukundareddy

Question #3569
(4) Write a program to perform all the logical operators on the following two variables, a= 10,b=5?
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS