Choose correct values the java code to print "hello" 10 times public class Test { public static void main(String args[]) { blank ; for( blank ; blank ; blank ) { blank } }int i i=1 i<=10 i++ System.out.println("hello"); i%10==0 i<=9 i<10
Question
Choose correct values the java code to print "hello" 10 times public class Test { public static void main(String args[]) { blank ; for( blank ; blank ; blank ) { blank } }int i i=1 i<=10 i++ System.out.println("hello"); i%10==0 i<=9 i<10
Solution
The correct values to fill in the blanks in the Java code to print "hello" 10 times are:
public class Test {
public static void main(String args[]) {
int i; // This declares the variable i
for(i=1; i<=10; i++) { // This sets up a loop that starts with i=1, ends when i>10, and increments i by 1 each time through the loop
System.out.println("hello"); // This prints "hello"
}
}
}
So the correct values for the blanks are int i, i=1, i<=10, i++, and System.out.println("hello"); respectively.
Similar Questions
Determine output:public class Test{ public static void main(String args[]){ int i, j; for(i=1, j=0;i<10;i++) j += i; System.out.println(i); }}1011920
Select the correct answerWhat would be the output of the following code snippet if variable p=10?if(p<=0){ if(p==0) { System.out.println("4 "); } else { System.out.println("5 "); }}System.out.println("6 ");Options1 21 362 3
What will be the output?public class Test{ public static void main(String args[]){ int i = 1; do{ i--; }while(i > 2); System.out.println(i); }}12-10
What will be the output of the program?public class Sample{ public static void main(String [] args) { int i = 10; do while ( i < 10 ) System.out.print("The value of i is " + i); while ( i > 10 ) ; }}Select one:a.No output is produced.b.The value of i is 10 The value of i is 10c.Compilation errord.The value of i is 10
Select the correct answerWhat will be the output of the following Java program?class java { public static void main(String args[]) { int w = 5; int x = 10; first: { second: { third: { if (w == x >> 1) break second; } System.out.println(w); } System.out.println(x); } } }Options5 1051010 5
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.