This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception" Watch "Exception" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
1. public void method(){
3. if (someTestFails()){
5. }
You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this?
A. Add at line 2: IOException e;
B. Add at line 4: throw e;
C. Add at line 4: throw new IOException();
D. Add at line 6: throw new IOException();
E. Modify the method declaration to indicate that an object of [type] Exception might be thrown.
answer : D , E.
I don't know why D is correct but not C.
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi Wong,
You are right, the answer should be C & E.
subject: Exception