Page 1 of 1

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

Posted: Tue Mar 24, 2015 3:17 pm
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.

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

Posted: Tue Mar 24, 2015 6:41 pm
by admin
The question is fine. You are not trying the code exactly as given.

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

Posted: Wed Mar 25, 2015 1:11 pm
by alkour
No, I run code exactly as it given.

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

Posted: Wed Mar 25, 2015 4:24 pm
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

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

Posted: Thu Mar 26, 2015 4:32 am
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?

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

Posted: Thu Mar 26, 2015 6:24 am
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.