About Question enthuware.ocajp.i.v7.2.1031 :
Moderators: Site Manager, fjwalraven
About Question enthuware.ocajp.i.v7.2.1031 :
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.
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 :
But in the website "enthuware.com"?????
I'm using the OCAJP kindle from Amazon.
I'm using the OCAJP kindle from Amazon.
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
In Kindle edition, you will find it at the end of the book. Under "Exam Refresher - Section 8 Handling Exceptions"
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.ocajp.i.v7.2.1031 :
Why does the fourth option does not have answer as ExceptionInIntializerError and why it's correct answer is "it will compile"
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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 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.
-
- Posts: 4
- Joined: Sat Oct 13, 2012 2:00 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
Online
HTH,
Paul.
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
Yes, java.lang.Class is a standard Java class, which has a forName method.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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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
I just get a ClassNotFoundException when I try to run this in Eclipse.
How is it used so that it compiles please?
Thanks
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
-
- Posts: 20
- Joined: Tue Aug 27, 2013 3:16 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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
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
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
-
- Posts: 4
- Joined: Tue Mar 03, 2015 12:28 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
-
- Posts: 3
- Joined: Sun Oct 25, 2015 1:45 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
In that case, the answer is "No exception will be thrown".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.
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.
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Sun Nov 06, 2016 12:46 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 : What is the
Hi,
Could you tell me the correct answer? Thanks.
I am answering the following: 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: Please, what is the correct answer?
Thanks.
Could you tell me the correct answer? Thanks.
I am answering the following: 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: Please, what is the correct answer?
Thanks.
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Sun Nov 06, 2016 12:46 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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.
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Tue Nov 22, 2016 7:58 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
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
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
Online
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1031 :
"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
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.
Who is online
Users browsing this forum: No registered users and 28 guests