Logical operator

Example of Logical operator AND and OR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package basic;
 
public class Logicaloperator {
 
	public static void main(String[] args) 
 
	{
		System.out.println(12&12);
 
		System.out.println(11&12);
 
		System.out.println(010|4);
		//010 is a octal number
		// 4 2 1    4 2 1            1000
		// 0 0 1    0 0 0            0100 //binary number of 4
		//                         = 1100   so ans=12
 
	}
}
 
output:
12
8
12

Leave a Reply

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