What does the following Java code display on the screen?int rows = 4; String output = "";for (int i = 0; i < rows; i++){ output = output + i; for (int j = 0; j < i; j++) output = output + "*";}System.out.print(output);Question 9Answera.0*1*2*3*b.01*2**3***c.01*2**3***4****d.0***1***2***3***e.None of the above
Question
What does the following Java code display on the screen?int rows = 4; String output = "";for (int i = 0; i < rows; i++){ output = output + i; for (int j = 0; j < i; j++) output = output + "";}System.out.print(output);Question 9Answera.0123b.0123c.01234d.0123***e.None of the above
Solution
The Java code provided will display the following on the screen:
0123
So, the correct answer is b. 0123
Similar Questions
What is the output of the following code snippet? int i = 5; while (i > 0) { System.out.print(i + " "); i--; }Question 14Answera.5 4 3 2 1 0b.4 3 2 1c.4 3 2 1 0d.5 4 3 2 1
What is the output of the following Java program?
What is the output of the following program? public class Test { public static void main(String[] args) { int[][] values = {{3, 4, 5, 1 }, {33, 6, 1, 2}}; for (int row = 0; row < values.length; row++) { java.util.Arrays.sort(values[row]); for (int column = 0; column < values[row].length; column++) System.out.print(values[row][column] + " "); System.out.println(); } } } Group of answer choicesThe program prints two rows 3 4 5 1 followed by 33 6 1 2.The program prints on row 3 4 5 1 33 6 1 2.The program prints two rows 3 4 5 1 followed by 2 1 6 33.The program prints two rows 1 3 4 5 followed by 1 2 6 33.The program prints one row 1 3 4 5 1 2 6 33.
What is displayed by the following code? _____ public static void main(String[] args) { String[] tokens = "Welcome to Java".split("o"); for (int i = 0; i < tokens.length; i++) { System.out.print(tokens[i] + " "); } }A. Welcome to JavaB. Welc me to JavaC. Welc me t JavaD. Welcome t Java
What would be output at the end of the following code segment? int num = 0; for(int row = 0; row < 7; row++ ) { for(int col = 0; col < 2; col++) { num++; } } System.out.println(num);a.)0b.)14c.)7d.)2
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.