About Question enthuware.ocajp.i.v7.2.1034 :
Moderator: admin
About Question enthuware.ocajp.i.v7.2.1034 :
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.
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.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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.
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.
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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
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
-
- Posts: 1
- Joined: Sat Nov 01, 2014 8:31 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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]);
}
}
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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.
-
- Posts: 2
- Joined: Mon Jul 20, 2020 1:30 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1034 :
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.
"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.
Who is online
Users browsing this forum: No registered users and 117 guests