题目内容

In a for statement, if the continuation condition is blank, the condition is assumed to be ______.

A. true
B. false

查看答案
更多问题

Analyze the following code:import javA.util.Scanner;public class Test { public static void main(String[] args) {int sum = 0;for (int i = 0; i < 100000; i++) {Scanner input = new Scanner(System.in);sum += input.nextInt();}}}

A. The program compiles and runs, but it is not efficient and unnecessary to execute the Scanner input = new Scanner(System.in); statement inside the loop. You should move the statement before the loop.
B. The program compiles, but does not run because there is not prompting message for entering the input.
C. The program does not compile because the Scanner input = new Scanner(System.in); statement is inside the loop.
D. The program compiles, but does not run because the Scanner input = new Scanner(System.in); statement is inside the loop.

A variable declared in the for loop control can be used after the loop exits.

A. true
B. false

The following loop displays _______________.for (int i = 1; i <= 10; i++) {System.out.print(i + " ");i++;}

A. 1 2 3 4 5 6 7 8 9
B. 1 2 3 4 5
C. 2 4 6 8 10
D. 1 3 5 7 9

Is the following loop correct?for (; ; );

A. No
B. Yes

答案查题题库