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

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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

Hi

For this question, I'm not sure the StackOverFlowError for the factorial function is right.

I think a recursive factorial function has to run a lot more than the capacity of int to generate a StackOverFlow.

Could you look into this please?

Thank you.

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

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

Post by admin »

The given question and answer are correct. It will throw java.lang.StackOverflowError for large integer values.

You are probably confusing Arithmetic overflow with Stack overflow. Both are different things.

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.1034 :

Post by Guest »

Hi sorry about that, I just realised that after putting in the question. But I was going to bed (got very less sleep before my exam), so couldn't correct the question.

Yeah I was actually confused it with Arithmetic overflow. While going to sleep is when I realised that 1000's of recursion itself could cause stack overflow, so yeah the answer is valid.

Anyway I gave my OCA exam today and passed. Thanks a lot to enthuware. :)

Thanks
Sreeju

Quadro
Posts: 1
Joined: Sat Nov 01, 2014 8:31 am
Contact:

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

Post by Quadro »

The following snippet will throw ArraIndexOutOfBoundsException, not NullPointerException as marked correct answer:

Code: Select all

void printMe(Object[] oa) {
    for(int i = 0; i <= oa.length; i++) {
        System.out.println(oa[i]);
    }
}

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

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

Post by admin »

No, it is correct. You probably overlooked the statement: Assume that it is called as such: printMe(null)
If you like our products and services, please help us by posting your review here.

se.le7204
Posts: 2
Joined: Mon Jul 20, 2020 1:30 pm
Contact:

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

Post by se.le7204 »

I just had a small point. If the question states "Identify the exceptions that will be received..." Wouldn't StackOverFlowError be an invalid answer since it is technically not an exception?

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

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

Post by admin »

The following convention is used in the exam:
"exception" with lower case e, as in "exception handling", refers to all kinds of exceptions i.e. all Throwables (Exception, Errors, RuntimeException and so on).
"Exception" with upper case E refers to java.lang.Exception.
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 32 guests