CAN Someone help with these questions? 1. What is the output of the following co
ID: 3594956 • Letter: C
Question
CAN Someone help with these questions?
1.
What is the output of the following code?
2.
Which conditional expression in the inner loop will print:
0
1
2
3
4
5
public class NestedLoop {
public static void main (String [] args) {
int userNum = 5;
int i = 0;
int j = 0;
for (i = 0; i <= userNum; i++) {
for (/* what code goes here? */) {
System.out.print(" ");
}
System.out.println(j);
}
return;
}
}
PreviousNext
3.
What will be the output of the following code snippet?
The output will be a right triangle of asterisks. The number of columns increments by one on completion of one iteration of the inner loop.
The output will be a rectangle of asterisks.
The output will be a right triangle of asterisks. The number of columns decrements by one on completion of one iteration of the inner loop.
4.
What is the output of the code snippet given below?
1 3 5
5.
What is the output of the following code snippet?
No output because of compilation error.
6.
Which of the following code snippets displays the output exactly 10 times?
7.
Which of the following statements is true about the variable total in the code below?
It is the cause of an infinite loop.
8.
How many times does the following code snippet display "Howdy"?
ten times
9.
What will be the output of the following code?
public class Mystery {
public static void main(String[] args) {
int counter = 1;
for (int i = 1; i < 5; i++) {
counter = counter * 2;
}
System.out.println(counter);
return;
}
}
2
10.
What is the output of the following code?
1
11.
In a do while loop the conditional check is made ______ execution of the loop body.
j = 0; j < i; j++Explanation / Answer
1.
10
9
8
7
6
5
4
3
2
1
2.
a) j = 0; j < i; j++
3.
The output will be a rectangle of asterisks.
4.
1 3 5 …. (infinite loop)
5.
“Inside the while loop” will be displayed only once.
6.
while (i < 10)
{
System.out.println("This is example 2.");
i++;
}
7.
b) It contains the value 11 after the loop is finished executing.
8.
five times
9.
a) 16
10.
c) 3
11.
b) after
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.