This book is now obsolete Please use CSAwesome instead.
3.11. Medium Multiple Choice Questions¶
These problems are similar to those you will see on the AP CS A exam.
- That would be the answer if these were all decimal values, but they are not.
- 12 in octal is 10 in decimal and 111 in binary is 7 in decimal so this is 123 - 10 + 7.
- This would be the answer if it was 123 - 12 + 111 (binary) but the 12 is in octal.
- Remember that the rightmost digit in any base is the base to the 0th power which is 1.
- Remember that the 111 is in binary (base 2). Its decimal value is 7.
3-10-1: Which of the following would be the correct result from the following expression: 123 (decimal) - 12 (octal) + 111 (binary)?
- This would be true if it was printing just the maximum integer value.
- This might make sense, but adding one to the maximum integer value gives the minimum integer value.
- There will be a compile time error
- It will compile, but what will it do when you run it?
- Adding one to the maximum integer value gives the minimum integer value due to overflow.
- There will be a run time error
- This makes sense, but it is not what happens.
3-10-2: What will be printed by
System.out.println(Integer.MAX_VALUE + 1);?