About Question enthuware.ocajp.i.v7.2.841 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
yurifw
Posts: 2
Joined: Sun Sep 08, 2013 10:40 am
Contact:

About Question enthuware.ocajp.i.v7.2.841 :

Post by yurifw »

this is the method i have:

Code: Select all

public static void main (String [] args){
   a();
}
public static void a(){
   //non-throwing exception code...
}
public static void b() throws IOException{
   throw new IOException();
}
//no compilation error
then i change to the following:

Code: Select all

public static void main (String [] args){
   a(); //compilation error, unhandled exception
}
public static void a()  throws IOException{
   //not throwing exception code...
   b();
}
public static void b() throws IOException{
   throw new IOException();
}
if I declare that method a throws IOException, I would have to handle it when it is called, and the answer doesn't say anything about changing other parts of the code, so why is it correct? in the example above, declaring the throws clause still doesn't make it compile.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.841 :

Post by admin »

The question asks you to make your method compile i.e. the method a() in your example, Not some other method i.e. main() in your example. In your example, the problem exists in main not in a().

In other words, the question does not say that there is a main method that calls your method and you need to make everything compile.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

yurifw
Posts: 2
Joined: Sun Sep 08, 2013 10:40 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.841 :

Post by yurifw »

ok then, thanks,
interpretation can be tricky

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests