This week's book giveaway is in the Programmer Certification forum. We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
None of your answers are correct, unfortunately. Your answer to a is too small, and the answers for b and c are too big. (For either answer to c.) I suggest writing the code and modifying it to count how many times it multiplies. Maybe even print each time the pow() method is called.
posted 1 month ago
Liutauras Vilda wrote:Didn't check other answers, but [a] seems to be incorrect to me.
 I'm not longer sure. Wait.
Can you explain how you derived to such answer for [a]?
How would you go about answering these questions? I also believe my work is wrong for the first question.
Mike Simmons wrote:I suggest writing the code and modifying it to count how many times it multiplies. Maybe even print each time the pow() method is called.
Do you really need to print each time pow() is called? That would give an incorrect impression I think. Multiplication happens only in the else clause and the result of multiplication is the y within the same else clause.
Piet Souris wrote:Mike doesn't claim that the two are equal. It is just that printing both values might give you an idea how the two are related, maybe giving a clue how to prove that relationship.
I have worded it slightly imprecise. Just wanted to raise some question publicly so OP wouldn't decide blindly to follow advice and submit that as an answer.
posted 1 month ago
Yesterday evening, I wanted to propose the same thing as Mike did, had even written the code for it (including your comment) but just before I wanted to submit, I saw that Mike had already replied. And I realised his reply was far better than mine: he left that problem for OP to discover and solve.