Problem

What’s the Output?The product of two 32-bit integers is a 64-bit number. If the 32 most si...

What’s the Output?

The product of two 32-bit integers is a 64-bit number. If the 32 most significant bits are zero, then the result is simply the 32 least significant bits. However, if the most significant 32 bits are not zero, then overflow has occurred, but Java does not throw an ArithmeticException. Instead, Java returns the 32 least significant bits of the product. Indeed, the evaluation of the multiplication operator * on integers neverthrows a runtime exception.

a. What is the output of the following program?

   public class Testint   {      public static void main(String[ ] args)      {         Integer x = 2;         for (int i = 0; i<10; i++)         {            x = x * x;            System.out.println(x.equals(0));         }      }   }


b. What happens if

      int x = 2;   replaces      Integer x = 2;?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 14
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT