About Question enthuware.ocajp.i.v7.2.1356 :
Moderator: admin
-
- Posts: 28
- Joined: Fri Jan 02, 2015 12:13 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.1356 :
I miss an option here. I know some folks would be glad to choose 'infinitely many` if it were given .
-
- Posts: 63
- Joined: Fri Oct 31, 2014 6:31 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
This is bit diversion to the actual question and the options,
What if the options include, infinite loop, one should go for which one, between(infinite loop and none of the above) according to you.
Thanks,
GPAR
What if the options include, infinite loop, one should go for which one, between(infinite loop and none of the above) according to you.
Thanks,
GPAR
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
None of the above, because it is not an infinite loop.
If you like our products and services, please help us by posting your review here.
-
- Posts: 22
- Joined: Sun Jan 15, 2017 10:51 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
I believe this is a bit question, yes? The book I used to study did not mention bits at all anywhere, yet I have seen 3+ questions in 2 practice tests that cover this. The book states that it covers everything you need to know.
So for the real exam, should I learn how bits work and what values correspond to what? I'm awed when others start giving answers and discuss using bits, for my non-programming background self
Thank you!
So for the real exam, should I learn how bits work and what values correspond to what? I'm awed when others start giving answers and discuss using bits, for my non-programming background self
Thank you!
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
No, it is not really a bit question. It is a question that tests you on your knowledge of the values that an int can take. The actual MIN value or MAX value is not important here but just the fact that any int variable cannot keep incrementing or decrementing for ever. It will roll over at one point.
If you like our products and services, please help us by posting your review here.
-
- Posts: 21
- Joined: Mon Mar 02, 2020 3:38 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
Just a note, this question is marked as Very Tough. Don't know if this was the intent but imo an easy question
-
- Posts: 1
- Joined: Mon May 24, 2021 4:45 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
How do we know that loop keeps iterating...?
The explanation says "A do-while loop is always executed at least once. So in the first iteration, x is decremented and becomes 9. Now the while condition is tested, which returns true because 9 is less than 10. So the loop is executed again with x = 9. In the loop, x is decremented to 8 and the condition is tested again, which again returns true because 8 is less than 10."
HOWEVER, this does not make sense to me, they just say the loop is executed again after x is decremented. How do we know this from the code fragment? i put the code fragment below for reference...
int x = 10;
do{
x--;
System.out.println(x); // 1
}while(x<10);
There is nothing that indicates to me that the "do" block runs more than once because the "while" block is not there/ doesn't exist..... or am I missing something?
The only explanation I can think of is I am missing the idea of a do-while loop completely. Does the "do" block execute when the "while condition is true without regard to the "while" 's block or does it execute only when referred to from within the "while" block (ie Recursion type of effect) ...?
The explanation says "A do-while loop is always executed at least once. So in the first iteration, x is decremented and becomes 9. Now the while condition is tested, which returns true because 9 is less than 10. So the loop is executed again with x = 9. In the loop, x is decremented to 8 and the condition is tested again, which again returns true because 8 is less than 10."
HOWEVER, this does not make sense to me, they just say the loop is executed again after x is decremented. How do we know this from the code fragment? i put the code fragment below for reference...
int x = 10;
do{
x--;
System.out.println(x); // 1
}while(x<10);
There is nothing that indicates to me that the "do" block runs more than once because the "while" block is not there/ doesn't exist..... or am I missing something?
The only explanation I can think of is I am missing the idea of a do-while loop completely. Does the "do" block execute when the "while condition is true without regard to the "while" 's block or does it execute only when referred to from within the "while" block (ie Recursion type of effect) ...?
-
- Site Admin
- Posts: 10074
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1356 :
In the do-while construct, the block of code following do, is the while's block. There is no other while block. This is a bit different from the while loop construct where the while's block follows the while keyword.
So yes, in the case of a -do-while loop, if the while's condition is true, then the block of code written above is executed again.
Please go through this trail to get the basics of the while and do-while loops: https://docs.oracle.com/javase/tutorial ... while.html
Or go through any good Java book.
So yes, in the case of a -do-while loop, if the while's condition is true, then the block of code written above is executed again.
Please go through this trail to get the basics of the while and do-while loops: https://docs.oracle.com/javase/tutorial ... while.html
Or go through any good Java book.
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 9 guests