16. When adding two n-bit 2’s complement numbers, overflow will NOT occur, if a.
ID: 3907630 • Letter: 1
Question
16. When adding two n-bit 2’s complement numbers, overflow will NOT occur, if
a. Both operands have different sign bits
b. Both operands have same sign bits, and the sign bit of the result is also same
c. Carry-in bits to MSBs are same as the Carry-out bit from the MSB
d. All of the above
21.
byte a = 127; // or a = 0x7F
System.out.println(++a);
In Java programming language the data type byte is implemented as 8-bit two’s compliment integer. What will be printed when the following code snippet is executed?
a. 128
b. -128
c. 0
d. Run time error
22. In Java programming language the data type int is represented as 32-bit two’s compliment integer. What will be printed when the following code snippet is executed (0x stand for Hex)? Why?
int b = 0xFFFFFFFF; // hex representation
System.out.println(++b);
a. 0x10000000, because 0xF + 1 = 0x10
b. 0, because 0xFFFFFFFF will be stored as -1
c. -1, because 0xFFFFFFFF will be stored as 0
d. 0xFFFFFFFG, because 0xF + 1 = 0xG
26.
lw $8, 4($16)
sw $8, 0($16)
Consider the following code: Assume $16 has the starting address of an array A. Which of the following Java code describes this MIPS code?
a. A[8] = A[16]
b. A[0] = A[1]
c. A[1] = A[0]
d. A[A[16]+4] = A[8]
byte a = 127; // or a = 0x7F
System.out.println(++a);
Explanation / Answer
Q16
All of these are correct
Q21
The answer is -128
Q22
0, because 0xFFFFFFFF will be stored as -1
Q26
Option B is correct according to the code
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.