What will be the output of the following Java program? [code] class bitwise_operator { public static void main(String

Đức Linh

New member
What will be the output of the following Java program?
Code:
    class bitwise_operator 
    {
        public static void main(String args[]) 
        {    
             int a = 3;
             int b = 6;
 	     int c = a | b;
             int d = a & b;             
             System.out.println(c + " "  + d);
        } 
    }
A. 7 2
B. 7 7
C. 7 5
D. 5 2
 
Answer: a
Explanation: And operator produces 1 bit if both operand are 1. Or operator produces 1 bit if any bit of the two operands in 1.
output:
Code:
$ javac bitwise_operator.java
$ java bitwise_operator
7 2
 

Tìm kiếm

Back
Top