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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User » Sun Feb 17, 2013 9:07 pm

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: 8702
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Feb 17, 2013 9:41 pm

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

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 » Sat Nov 01, 2014 9:05 am

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: 8702
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Nov 01, 2014 11:24 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests