I have two doubts
1) I thought the following statement would be illegal but it isn't:
double d = 0x12345678;
The K&B book says nothing about double variables holding hexadecimal values. It just says, quote
All three integer literals (octal, decimal, and hexadecimal) are defined as int by default, but they may also be specified as long by placing a suffix of L or 1 after the number
If double can hold hexadecimal values, shouldn't the Double (wrapper) class's valueOf method be overloaded to take base/radix as argument?
2) My second question concerns this:
What letters get written to the standard output with the following code?
class Unchecked {
public static void main(
String[] args) {
try {
method();
} catch (Exception e) {
}
}
static void method() {
try {
wrench();
System.out.println("a");
} catch (ArithmeticException e) {
System.out.println("b");
} finally {
System.out.println("c");
}
System.out.println("d");
}
static void wrench() {
throw new NullPointerException();
}
}
Select all valid answers.
1. "a"
2. "b"
3. "c"
4. "d"
5. none of these
The answer is 3 (only "c" is printed), but my question is that since NullPointerException is a RuntimeException, it doesn't have to be caught. So shouldn't the output be "a", "c" and "d"?
[ September 01, 2007: Message edited by: Sachin Kapoor ]