Computer Science, asked by eyepatchthegamer, 13 hours ago

Write the output of: System.out.println(“12+15=” +12+15);​

Answers

Answered by shijopaul2008
1

Answer:

system.out.println(12>>2);

output--> 3

consider 8-bit

binary of 12

0000 1100

>>1( right shift one : insert one Zero from left)

then bit pattern will be

0000 0110(which is 6)

>>1(again right shift one : insert another Zero from left)

then bit pattern will be

0000 0011(which is 3)

Simply when we right shift by one then divide given number by two

e.g

12>>1 -- 12/2=6

12>>2 -- 12/2=6 -- 6/2=3Image Created0Down

By: [email protected] On: Thu Apr 18 12:15:00 IST 2013 Question Reputation15 Answer Reputation32 Belt Series Points0  47User Image

Are You Satisfied :7Yes4No

it is simply 12>>2 means 12/2^2=3.Image Created0Down

By: [email protected] On: Thu Apr 18 12:49:20 IST 2013 Question Reputation0 Answer Reputation147 Belt Series Points0  147User Image

Are You Satisfied :2Yes2No

public class ShiftOperatorCheck {

public static void main(String[] args) {

//binary of 12 --> 1100

System.out.println(Integer.toBinaryString(12));

// 12>>2 means shift 2 bits right

// means 12 biary 1100, after shifting 0011 or 3 in decimal so

System.out.println(12>>2);//will give 3 as result

}

}

Similar questions