Khoka Babu !!!

Observe the following coding in Java -- How many times will "Khoka Babu!!" displayed??

 int b=(Byte.MAX_VALUE+(int)Math.abs(Byte.MIN_VALUE)+6);
 int r=(byte)b;
 boolean t=true;
    for(int i=1;t;i++)
         {
                System.out.println("Khoka Babu!!");
                t=i<r--;
          }  // log on to www.comprogzz.in  for such java coding
5 6 9 3

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Ahmad Elsagheer
Jun 27, 2014

b has the value 127 + |-128| + 6 which will be 5 when truncated to be stored in the byte variable r ... performing the for loop, we will find t is true 3 times (first time, 1 < 5, 2 < 4)

I just point at random choices since it didnt explain what does int b=(Byte.MAX VALUE+(int)Math.abs(Byte.MIN VALUE)+6); do. not a java man here

Roi Vinson Abrazaldo - 6 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...