Unit 4: Iteration
Showing 20 of 25 questions
What is the output of the following code?
How many times does "*" get printed?
What is the output of the following code?
What is the output of the following code?
What is the value of x after the following code executes?
What is the output of the following code?
What is the output of the following code?
How many times is "Hi" printed?
What is the output of the following code?
What is the output of the following code?
What is the output?\nfor (int i = 0; i < 5; i++) System.out.print(i + " ");
How many times does the loop execute?\nint x = 10;\nwhile (x > 0) { x -= 3; }
How many times is "*" printed?\nfor (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) System.out.print("*");
Which loop correctly iterates through all elements of int[] arr?
To iterate through each character of a String str, which loop header is correct?
Which of the following creates an infinite loop?
What is the value of sum after this code?\nint sum = 0;\nfor (int i = 1; i <= 5; i++) sum += i;
How many times does this loop execute?\nint x = 100;\nwhile (x < 10) { x++; }
What does this code output?\nString s = "Java";\nString result = "";\nfor (int i = s.length() - 1; i >= 0; i--) result += s.charAt(i);\nSystem.out.println(result);
What does this code produce?\nString s = "Hello World";\nint count = 0;\nfor (int i = 0; i < s.length(); i++) if (s.charAt(i) == 'l') count++;\nSystem.out.println(count);
Advertisement