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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Alina_Lapina
Posts: 15
Joined: Tue Jan 13, 2015 12:10 pm
Contact:

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

Post by Alina_Lapina »

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!

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

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

Post by admin »

Well, that's great news!
thank you for sharing your experience and information.
If you like our products and services, please help us by posting your review here.

mj.anjuthan
Posts: 10
Joined: Thu Nov 10, 2016 3:07 am
Contact:

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

Post by mj.anjuthan »

This is really a tricky ambiguous question.

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();		
}
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.

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

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

Post by admin »

FileNotFoundException. Always go with most specific answer, if possible.
-Paul.
If you like our products and services, please help us by posting your review here.

ananias
Posts: 3
Joined: Fri Jun 29, 2018 1:33 am
Contact:

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

Post by ananias »

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

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

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

Post by admin »

Please go through the complete discussion above.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

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

Post by flex567 »

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 ?

Javier
Posts: 66
Joined: Mon Feb 20, 2017 12:31 pm
Contact:

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

Post by Javier »

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!

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

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

Post by admin »

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

Javier
Posts: 66
Joined: Mon Feb 20, 2017 12:31 pm
Contact:

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

Post by Javier »

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!

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

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

Post by admin »

Yes, that is correct.
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 50 guests