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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

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

Post 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.

ETS User

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

Post by ETS User »

But in the website "enthuware.com"?????

I'm using the OCAJP kindle from Amazon.

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

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

Post by admin »

In Kindle edition, you will find it at the end of the book. Under "Exam Refresher - Section 8 Handling Exceptions"

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

Guest

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

Post by Guest »

Why does the fourth option does not have answer as ExceptionInIntializerError and why it's correct answer is "it will compile"

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

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

Post 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.]
If you like our products and services, please help us by posting your review here.

mehtapra
Posts: 4
Joined: Sat Oct 13, 2012 2:00 pm
Contact:

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

Post 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.

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

Robyn

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

Post 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

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

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

Post by admin »

It is difficult to figure out the issues with IDEs. Please use command line and notepad.
If you like our products and services, please help us by posting your review here.

Zoryanat
Posts: 20
Joined: Tue Aug 27, 2013 3:16 am
Contact:

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

Post 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

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

johnorben
Posts: 4
Joined: Tue Mar 03, 2015 12:28 pm
Contact:

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

Post 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.

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

Kev1np
Posts: 3
Joined: Sun Oct 25, 2015 1:45 pm
Contact:

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

Post 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.

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

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

Post 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.
If you like our products and services, please help us by posting your review here.

mglara
Posts: 2
Joined: Sun Nov 06, 2016 12:46 pm
Contact:

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

Post 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 9531 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 9531 times
Please, what is the correct answer?

Thanks.

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

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

Post 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 9529 times
If you like our products and services, please help us by posting your review here.

mglara
Posts: 2
Joined: Sun Nov 06, 2016 12:46 pm
Contact:

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

Post 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 9528 times

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

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

Post 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 9527 times
If you like our products and services, please help us by posting your review here.

Far777
Posts: 1
Joined: Tue Nov 22, 2016 7:58 am
Contact:

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

Post 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

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

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

Post 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
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests