About Question enthuware.ocajp.i.v7.2.852 :
Moderator: admin
-
- Posts: 15
- Joined: Tue Jan 13, 2015 12:10 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
On Monday, January, 19 2015, I was at the real 1Z0-803 exam and got an almost similar question. There wasn't the "IndexOutOfBoundsException" opthion. There was only "StringIndexOutOfBoundsException", "ArrayIndexOutOfBoundsException" and several checked exceptions. It look like they have fixed it. Relax! And good luck on your exam!
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Well, that's great news!
thank you for sharing your experience and information.
thank you for sharing your experience and information.
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Thu Nov 10, 2016 3:07 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
This is really a tricky ambiguous question.
Considering the following code, what should we answer?
What should be the answer to the following two possible questions?
Question 1) What will the following code print?
Question 2) What will the exception thrown when the code is compiled and run?
Say the options of both questions have "It throws IOException" and "It throws FileNotFoundException" and other options are obviously wrong.
Considering the following code, what should we answer?
Code: Select all
static void testMethod() throws IOException{
throw new FileNotFoundException();
}
public static void main(String[] args) throws IOException{
testMethod();
}
Question 1) What will the following code print?
Question 2) What will the exception thrown when the code is compiled and run?
Say the options of both questions have "It throws IOException" and "It throws FileNotFoundException" and other options are obviously wrong.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
FileNotFoundException. Always go with most specific answer, if possible.
-Paul.
-Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Fri Jun 29, 2018 1:33 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Bellow is the code I extracted from The String class:
public char charAt(int index) {
if ((index < 0) || (index >= value.length)) {
throw new StringIndexOutOfBoundsException(index);
}
return value[index];
}
I still don't uderstand how IndexOutOfBoundsException will be thrown instead of StringIndexOutOfBoundsException
public char charAt(int index) {
if ((index < 0) || (index >= value.length)) {
throw new StringIndexOutOfBoundsException(index);
}
return value[index];
}
I still don't uderstand how IndexOutOfBoundsException will be thrown instead of StringIndexOutOfBoundsException
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Please go through the complete discussion above.
If you like our products and services, please help us by posting your review here.
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Is there a list of ALL things we need to know for the examp by heart?
All APIs and which methods, All exception classes, All Date constants ...
I know that there are posts about that in the forum but is there one post that contain all the information ?
All APIs and which methods, All exception classes, All Date constants ...
I know that there are posts about that in the forum but is there one post that contain all the information ?
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Hi Enthuware!
Now I have a big doubt. So ArrayIndexOutOfBoundsException and StringIndexBoundsException shouldn´t be answered like correct in the test? Should we answer IndexOutOfBoundsException any time?
Thank you in advance!
Now I have a big doubt. So ArrayIndexOutOfBoundsException and StringIndexBoundsException shouldn´t be answered like correct in the test? Should we answer IndexOutOfBoundsException any time?
Thank you in advance!
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Yes, in our opinion, you should go with what the JavaDoc says. In this case, it is IndexOutOfBoundsException.
I will also suggest you not to worry too much about this issue for the exam.
HTH,
Paul.
I will also suggest you not to worry too much about this issue for the exam.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 66
- Joined: Mon Feb 20, 2017 12:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Hi again Paul!
In this example we have to say IndexOutOfBoundsException instead of StringIndex...(I read in the API that is throwing IndexOutOfBoundsException)
"test".substring(2,1); // IndexOutOfBoundsException
Am I right Paul?
Thank you very much!
In this example we have to say IndexOutOfBoundsException instead of StringIndex...(I read in the API that is throwing IndexOutOfBoundsException)
"test".substring(2,1); // IndexOutOfBoundsException
Am I right Paul?
Thank you very much!
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.852 :
Yes, that is correct.
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 50 guests