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.
About Question enthuware.ocajp.i.v7.2 . 1005 :
Moderator: admin
-
- Posts: 30
- Joined: Tue Mar 24, 2015 2:59 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1005 :
The question is fine. You are not trying the code exactly as given.
-
- Posts: 30
- Joined: Tue Mar 24, 2015 2:59 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1005 :
No, I run code exactly as it given.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1005 :
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
-
- Posts: 30
- Joined: Tue Mar 24, 2015 2:59 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2 . 1005 :
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?
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?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2 . 1005 :
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.
Who is online
Users browsing this forum: Bing [Bot] and 9 guests