Question: Suppose that a variable a is declared as int a = 2147483647 (or equivalently, Integer.MAX_VALUE). What does each of the following print? a. System.out.println(a); b.

Suppose that a variable a is declared as int a = 2147483647 (or equivalently, Integer.MAX_VALUE). What does each of the following print?

a. System.out.println(a);

b. System.out.println(a+1);

c. System.out.println(2-a);

d. System.out.println(-2-a);

e. System.out.println(2*a);

f. System.out.println(4*a);

Explain each outcome.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This question is about integer overflow and underflow In Java the integer type int is a 32bit signed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming Questions!