Page 1 of 1

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

Posted: Sun Feb 17, 2013 9:07 pm
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.

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

Posted: Sun Feb 17, 2013 9:41 pm
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.

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

Posted: Mon Feb 18, 2013 5:54 pm
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

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

Posted: Sat Nov 01, 2014 9:05 am
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]);
    }
}

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

Posted: Sat Nov 01, 2014 11:24 am
by admin
No, it is correct. You probably overlooked the statement: Assume that it is called as such: printMe(null)

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

Posted: Mon Jul 20, 2020 1:34 pm
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?

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

Posted: Mon Jul 20, 2020 9:15 pm
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.