Put the lines of code in the correct order to print: 1,2,3,4,5. 1. Line 1 2. Lin
ID: 3835881 • Letter: P
Question
Put the lines of code in the correct order to print: 1,2,3,4,5.
1. Line 1
2. Line 2
3. Line 3
4. Line 4
5. Line 5
6. Line 6
Answer Choices:
A. System.out.print(x);
B. while (x 5) {
C. System.out.print("," + x);
D. }
E int x = 1;
F x++;
Put the lines of code in the correct order to print: 1,2,3,4,5.
1. Line 1
2. Line 2
3. Line 3
4. Line 4
5. Line 5
6. Line 6
Answer choices:
A. System.out.print(x + ",");
B.int x = 1;
C.while (x 5) {
D.System.out.print(x);
E.x++;
F.}
Suppose rand is a Random object. Match each of the following method calls to the range of possible values.
1. rand.nextBoolean( )
2. rand.nextInt(10)
3. 1 + rand.nextInt(10)
4. 2 * rand.nextDouble( )
5. -1 + 2 * rand.nextDouble( )
Answer Choices
A.a double between 0 and 2
B an int from 1 to 10
C an int from 0 to 9
D a double between -1 and 1
E true or false
Second Part
What is the flow of control for a do/while loop?
Answer Choices: A. If the test is true, go to Step 1, else go to the next step. B.Execute the body of the do/while loop. C. Execute the statement(s) after the do/while. D. Evaluate the do/while loop test.
1. Step 1
2. Step 2
3. Step 3
4. Step 4
Explanation / Answer
(1) Answer for the first question is as follows.
The lines of code in the correct order to print: 1,2,3,4,5. is as follows
1. E
2. A
3. B (Expression should be x<5)
4. C
5. F
6. D
(2) Answer for the second question is as follows.
1. B
2. C (Expression should be x<5)
3. A
4. E
5. F
6. D
Answer for the third question is as follows.
1. E
2. C
3. B
4. A
5. D
Answer for the fourth question is as follows. (Second part)
1. D
2. A
3. B
4. C
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.