Page 1 of 1

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

Posted: Mon Sep 03, 2012 2:45 pm
by ETS User
Hi,

Reading the answer about this question I can see:

"Please read ExceptionClassSummary document in the 'Study References' section"....

Where is the Study References section???

Thanks in advance.

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

Posted: Mon Sep 03, 2012 3:25 pm
by ETS User
But in the website "enthuware.com"?????

I'm using the OCAJP kindle from Amazon.

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

Posted: Mon Sep 03, 2012 4:13 pm
by admin
In Kindle edition, you will find it at the end of the book. Under "Exam Refresher - Section 8 Handling Exceptions"

HTH,
Paul.

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

Posted: Wed Oct 03, 2012 12:02 am
by Guest
Why does the fourth option does not have answer as ExceptionInIntializerError and why it's correct answer is "it will compile"

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

Posted: Wed Oct 03, 2012 6:23 am
by admin
4th option doesn't compile because the compiler determines at compile time that the class initialization in this case does not complete normally.

If you change it to something like if(true) throw new NullPointerException();

it will compile fine and will throw ExceptionInIntializerError because now the compiler can't determine. [Although if(true) can be correctly determined at compile time itself, Java specification has allowed this as a special case where the compiler doesn't generate an error. This is done to support the feature of conditional compilation.]

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

Posted: Sat Oct 20, 2012 12:32 pm
by mehtapra
In the 3rd option: Class.forName("java.lang.String") are we assuming that Class is a valid class with a method forName(String s) in it? If not, than it should give answer as it won't compile.

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

Posted: Sun Oct 21, 2012 6:55 am
by admin
mehtapra wrote:In the 3rd option: Class.forName("java.lang.String") are we assuming that Class is a valid class with a method forName(String s) in it? If not, than it should give answer as it won't compile.
Yes, java.lang.Class is a standard Java class, which has a forName method.

HTH,
Paul.

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

Posted: Sat Mar 09, 2013 1:22 pm
by Robyn
In the third question: Class.forName("java.lang.String");

I just get a ClassNotFoundException when I try to run this in Eclipse.

How is it used so that it compiles please?

Thanks

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

Posted: Sat Mar 09, 2013 2:47 pm
by admin
It is difficult to figure out the issues with IDEs. Please use command line and notepad.

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

Posted: Wed Oct 30, 2013 9:25 pm
by Zoryanat
I cannot find ExceptionClassSummary.pdf on my computer - it is missing from System32 folder and when I click on "Exception Class Summary" in "Study Reference" section - I am getting an error message saying that access to file in System32 was denied. And I have checked that folder manually, making sure that I display hidden files.
Google search brought no luck - I cannot find this document. Could you please send it to me?
My email is zoryanat@ie.ibm.com.
Many thanks!
Regards
Zoryana

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

Posted: Mon Nov 04, 2013 8:58 pm
by admin
Very sorry about that. I missed your post. You can download it from here: http://enthuware.com/downloads/Exceptio ... ummary.pdf

BTW, you are getting the error because it is not able to extract the file in that location (c:\windows\system32). Please run ETS Viewer from a non-system location such as c:\temp and it should work.

HTH,
Paul.

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

Posted: Thu Mar 12, 2015 8:36 am
by johnorben
This works:
public class forName {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws ClassNotFoundException {
// TODO code application logic here
Class.forName("java.lang.String");

}

}


But the question is not really valid as displayed, because you have to assume that the throws clause is included in the method declaration.

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

Posted: Thu Mar 12, 2015 9:34 am
by admin
No assumption is required here because the question makes it clear that an exception will be received when the given code snippet is executed. You have to find out which one. It doesn't care how that exception is handled i.e. whether there is a method with a throws clause or a try/catch encompassing the given code snipped.

It is the same in real exam as well. You may be given an incomplete block of code and you will have to answer based on the information given. Any information that is not given is irrelevant to the question.

HTH,
Paul.

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

Posted: Mon Nov 02, 2015 11:27 am
by Kev1np
admin wrote:No assumption is required here because the question makes it clear that an exception will be received when the given code snippet is executed. You have to find out which one. It doesn't care how that exception is handled i.e. whether there is a method with a throws clause or a try/catch encompassing the given code snipped.

It is the same in real exam as well. You may be given an incomplete block of code and you will have to answer based on the information given. Any information that is not given is irrelevant to the question.

HTH,
Paul.
In that case, the answer is "No exception will be thrown".
When "Will not compile" is a valid answer and a method which throw a checked exception isn't surrounded with a try/catch block, i think it's legit to say it will not compile.

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

Posted: Mon Nov 02, 2015 9:26 pm
by admin
If the given code shows a complete method and the code inside that method shows a checked exception being thrown and the method does not have an appropriate throws, then yes, "Will not compile" would be the correct option. But that is not the case in this question.

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v7.2.1031 : What is the

Posted: Sun Nov 06, 2016 2:44 pm
by mglara
Hi,

Could you tell me the correct answer? Thanks.

I am answering the following:
My answer
My answer
answers1031.JPG (47.78 KiB) Viewed 11318 times
And I have tried different combinations, like for example:

//first attempt// (the one I did the screenshot, and I think it is correct, but the simulator says it is
wrong)
1-> NullPointerException
2-> ArrayIndexOutOfBoundsException
3-> ClassNotFoundException
4->Will not compile

//second attempt//
1-> NullPointerException
2-> ArrayIndexOutOfBoundsException
3-> Will not compile
4->ExceptionInInitializerError

//third attempt//
1-> NullPointerException
2-> ArrayIndexOutOfBoundsException
3-> ClassNotFoundException
4->ExceptionInInitializerError

//fourth attempt//
1-> NullPointerException
2-> ArrayIndexOutOfBoundsException
3-> Will not compile
4->Will not compile


But the exams always answer me this:
Correction.JPG
Correction.JPG (50.28 KiB) Viewed 11318 times
Please, what is the correct answer?

Thanks.

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

Posted: Sun Nov 06, 2016 10:50 pm
by admin
Hi,
There is a "Show Correct Answer" button on the bottom right of the DnD screen. Click on it to see the correct answer. Please see attached image.
test.png
test.png (17.73 KiB) Viewed 11316 times

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

Posted: Sat Nov 12, 2016 10:12 am
by mglara
Hi Admin,

Thanks for posting the correct screenshot with the answer.

I was aware about that button, but it is not working for my program. I have done an update, but the button to see the correct answer doesn't work, then, I need to check the explanation that the software provides when we close the "Drag and drop viewer". I attached an screenshot, and you can see it is not clickable.
correctAnswerButton.JPG
correctAnswerButton.JPG (12.69 KiB) Viewed 11315 times

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

Posted: Sat Nov 12, 2016 10:39 am
by admin
The button is disabled because of one of the following two reasons:
1. You are in a test and have not yet finished the test. It will be enabled once you finish the test.
2. You have opened the question out side of a test and have not yet clicked on "Evaluate" button on the main question dialog. See attached image. Once you click evaluate, the DnD dialog will allow to you see the correct answer. This is done to ensure that you don't see the answer by mistake before attempting it yourself.

HTH,
Paul.
test2.png
test2.png (9.23 KiB) Viewed 11314 times

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

Posted: Mon Nov 28, 2016 6:59 am
by Far777
I cannot find ExceptionClassSummary.pdf on my computer - it is missing from System32 folder and when I click on "Exception Class Summary" in "Study Reference" section - I am getting an error message saying that access to file in System32 was denied. And I have checked that folder manually, making sure that I display hidden files.
Google search brought no luck - I cannot find this document. Could you please send it to me?
My email is f.aziz9999@gmail.com
Many thanks!
Regards
Far

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

Posted: Mon Nov 28, 2016 7:09 am
by admin
"Access Denied" means it is not able to extract the file to that location because it was denied access to it by the OS. Please run ETS Viewer as admin and it will be able to.
You may download the file from here: http://enthuware.com/downloads/Exceptio ... ummary.pdf