Question

1. (a) Before entering any while loop, the while loop condition is. . . A. true...

1. (a) Before entering any while loop, the while loop condition is. . . A. true B. false C. true or false

(b) At the beginning of each iteration, a while loop condition is. . . A. true B. false C. true or false

(c) When the loop terminates, a while loop condition is. . . A. true B. false C. true or false

(d) Which of the following statements will not cause a compile-time error? A. byte b = 1543; B. int n = (int) "Hi there"; C. int i = 34.13; D. long k = (int) 92.12;

(e) The first statement in a for-loop header is performed. . . A. at the beginning of each iteration. B. at the end of each iteration. C. only once, just before entering the loop. D. only once, just before exiting the loop.

(f) Overflow is... A. When attempting to store a value in a variable of the wrong type. B. When an else block is not aligned with the corresponding if block. C. When a switch statement passes from one case to the next, because there is no break keyword. D. When integer arithmetic causes an integer variable with a large positive value to wrap around to an equally large negative value (or vice versa).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) Before entering any while loop, the loop condition could be true or false and based its value only compiler decides whether to go inside loop or not.

b) At beginning of each iteration, the condition of each iteration is true.

c) When loop terminates loop condition is false, that's why the loop terminated.

d) long k = (int) 92.12 doesn't create compile time error as here we are converting 92.12 to int and trying to store in long which is up casting and long can store an int.

Other three will result in compile time error, like

e) Its executed at the beginning of each iteration.

f) Overflow is when integer arithmetic causes an integer variable with a large positive value to wrap around to an equally large negative value (or vice versa)

Add a comment
Know the answer?
Add Answer to:
1. (a) Before entering any while loop, the while loop condition is. . . A. true...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 21 The loop condition can be a complex condition involving several operators. True OR False...

    Question 21 The loop condition can be a complex condition involving several operators. True OR False Question 22 final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87; if(num3-5 >= 2*LIMIT) { System.out.println ("apple"); } else { System.out.println ("orange"); } System.out.println("grape"); What prints? A. Apple B. Orange C. Grape D. apple grape E. orange grape F. Nothing. Question 23 When we use a while loop, we always know in advance how many...

  • 1. True/False: An infinite loop occurs in a pre-test loop when a test condition can never...

    1. True/False: An infinite loop occurs in a pre-test loop when a test condition can never be met.      2. True/False: An infinite loop occurs in a post-test loop when a test condition can never be met. 3. True/False: The following statement will generate a loop with four iterations:                            for(count = 4; count > 0; count--) 4. True/False: The problem with a do...while loop is that the test condition cannot be a compound condition. 5. True/False: The following test...

  • need asap Homework (5) 1. There are two basic forms of loop constructs: - and 2....

    need asap Homework (5) 1. There are two basic forms of loop constructs: - and 2. Which of the following is an alternate and faster way of performing the same function as many MATLAB for loops? a) a. Exhaustive enumeration b) b. Vectorization c) c. Variable declaration d) d. Amortization 3. A while loop is a block of statements that are repeated indefinitely as long as some condition is satisfied. a) True b) False 4. The for loop is a...

  • For the while loop below, use the loop invariant given to show that if the pre-condition...

    For the while loop below, use the loop invariant given to show that if the pre-condition is the loop.In each step, clearly state true before the loop then the post-condition is true after what facts are assumed and what facts will be proven. (computes the sum of a list of numbers.) fa ,an While (<n) sum := sum + am j j+1 End-while ° Pre-condition: j- 1, sum a, n is a positive integer, a,,.. a, is a list of...

  • Question 37 The body of a while loop is executed until the loop condition becomes true...

    Question 37 The body of a while loop is executed until the loop condition becomes true false None of the above.

  • What is a post-condition of a loop in C#? Select all that apply. A. D. Logic...

    What is a post-condition of a loop in C#? Select all that apply. A. D. Logic inside a loop code block that indicates infinite repetition of a loop. B. B. A true/false indicator that indicates when the loop should end. C. A. A logic that indicates when the loop should end and jump off the loop. D. C. Condition inside a loop code block that tells the loop to continue.

  • for c++ Suppose cond1 is a Boolean expressions. When will this while condition be true? while...

    for c++ Suppose cond1 is a Boolean expressions. When will this while condition be true? while (cond1) ... always false always true in case cond1 is false in case cond1 is true

  • 3. A tor loop is useful when you know in advance the number of iterations to...

    3. A tor loop is useful when you know in advance the number of iterations to be executed. The tor loop consists of three parts each of which is separated by a semicolon (:). The first part is initialization of the variable for iteration, the second part is a test of the iteration variable and if this test fails, the loop is finished. The third part is a counter for the iteration variable. A block can be followed after the...

  • QUESTION 1 Which statement results in the value false? The value of count is 0; limit...

    QUESTION 1 Which statement results in the value false? The value of count is 0; limit is 10. (count != 0)&&(limit < 20) (count == 0)&&(limit < 20) (count != 0)||(limit < 20) (count == 0)&&(limit < 20) 10 points    QUESTION 2 If this code fragment were executed in an otherwise correct and complete program, what would the output be? int a = 3, b = 2, c = 5 if (a > b) a = 4; if (...

  • java QUESTION 4 Which of the following statements about a do...while repetition statement is true? A....

    java QUESTION 4 Which of the following statements about a do...while repetition statement is true? A. The body of a do...while loop is executed only if the terminating condition is true. B. The body of a do...while loop is executed only once. C. The body of a do...while loop is always executed at least once. D. None of the above QUESTION 5 To exit out of a loop completely and change the flow of control to the first line after...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT