| Author |
Question on K& B chapter 5.
|
Justin Russo
Ranch Hand
Joined: Oct 21, 2007
Posts: 77
|
|
three possible changes C1. Declare the main() throws an Exception C2. Declare the Ping.getInt() throws an Exception C3. Wrap the invocation of getInt() in try / catch block. which change(s) allow the code to compile (choose all that apply) A. Just C1 is sufficient B. Just C2 is sufficient C. Just C3 is sufficient D. Both C1 and C2 are required E. Both C1 and C3 are required F. Both C2 and C3 are required G. All three changes are required Answer was A and C My question is why B is considered incorrect when the question states that choose all that apply for successfully compilation. Also the answer in the book states that B is not ncessary so confused.. Please let me know the reason. thanks a lot!
|
You Want it.. Get it.......the Right Way...<br /> <br />SCJP 5.0 SCWCD 5.0
|
 |
ahmed yehia
Ranch Hand
Joined: Apr 22, 2006
Posts: 424
|
|
Hello Maybe you need to try to compile the program and see which options are required to make successful compile. However in main method you are invoking(at compile time) a method that might throw a checked Exception. Either you need to declare that the calling method which is 'main' to throw the Exception, or wrap the method call getInt() in a try/catch block.
|
 |
Matthias Wendel
Greenhorn
Joined: Sep 26, 2007
Posts: 10
|
|
Because makes the compiler complain that there is an in line 4. Regards, Matthias
|
 |
Justin Russo
Ranch Hand
Joined: Oct 21, 2007
Posts: 77
|
|
|
Thanks!!
|
 |
 |
|
|
subject: Question on K& B chapter 5.
|
|
|