About Question enthuware.ocajp.i.v7.2 . 1005 :

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

Moderator: admin

Post Reply
alkour
Posts: 30
Joined: Tue Mar 24, 2015 2:59 pm
Contact:

About Question enthuware.ocajp.i.v7.2 . 1005 :

Post by alkour »

There is no right answer in the list of answers.

I ran the programm. It did not compile with error: unreported exception Exception; must be caught or declared to be thrown
doA(15); // 3

Which is correct, becuase Exception is not decalared in method doB.

So answer list should be corrected.

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

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

Post by admin »

The question is fine. You are not trying the code exactly as given.

alkour
Posts: 30
Joined: Tue Mar 24, 2015 2:59 pm
Contact:

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

Post by alkour »

No, I run code exactly as it given.

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

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

Post by admin »

You must be making some mistake. I have verified that the question is correct. It doesn't compile.

Code: Select all

A.java:9: error: unreported exception Exception; must be caught or decla
red to be thrown
            doA(15); // 3
               ^
1 error

alkour
Posts: 30
Joined: Tue Mar 24, 2015 2:59 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2 . 1005 :

Post by alkour »

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - unreported exception java.lang.Exception; must be caught or declared to be thrown
at a.A.doB(A.java:12)
at a.A.main(A.java:20)
Java Result: 1

I use NetBeans. The same result.

The answer now is: "This will compile if throws Exception is added at line //2 as well as //4."

In my opnion it should be: "It will not compile. The Exception is thrown at line //3 as well as //4."

Am I correct?

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

Re: About Question enthuware.ocajp.i.v7.2 . 1005 :

Post by admin »

It is really difficult to comment on error messages displayed by IDEs. Please use the command line. That is what matters for the exam as well. As I mentioned before, the question and its explanation are correct. Please try it exactly as given.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests