Query in the output of below java code
public class qu11 { int fun(int num) {int count=0; while(num>0) { count++; num<<=1; } return count; } public static void main(String aa[]) { qu11 obj=new qu11(); int output= obj.fun(435); System.out.println(output); } }According to me the output of this question must be 8 but why is its output 23..
Replies
-
micheal johnradha gogiaAccording to me the output of this question must be 8 but why is its output 23..
can you explain how to got 8 as answer? -
rahul69435=> 9 bits, shifting one bit right ,and as int is 32 bit, so keeping counter,32-9=23.
You are reading an archived discussion.
Related Posts
Hello everyone. 😀
I am a second year student and I want to learn some designing. AutoCAD or Solid Edge? Which is better ?
I am intrested in solid edge...
The latest entrant to the sub-Rs. 5000 Android smartphone range in India is the all-new Intex Aqua Style X Smartphone that features Android 4.4 KitKat OS and a 4.5-inch touchscreen...
Airmail 2.0 has been released and as an avid supporter of the app, I bought an upgrade from the Mac App store in no time. I've been in love with...
Hi,
I need to ask will software testing be a good thing to start as a fresher?
I am BE in IT and been trained in java in cts.
Will...
Is there any opinion in this society about this phone?
I am practically clueless at what to look at while purchasing a smart phone. Recently I got blanked with Android...