Please just give me the correct letter for each problem. The language is java. 6
ID: 3863242 • Letter: P
Question
Please just give me the correct letter for each problem. The language is java. 6. What is y after the following switch statement is executed? int x 3 int y 4; switch (x 3) case 6: v 0; break; case 7: y 1;break; default: y 1; A. 1 B. 2 C. 3 D. 4 7. How many times will the following code print "Welcome to Java"? int count- 0; do System out.println ("Welcome to Java"); count++; while (count 10); A, 8 B. 9 C. 10 E. 0 8. How many times will the following code print "Welcome to Java"? nt count 0; while (count 10) system out.println("Welcome to Java"); A. 8 B. 9 E. 0Explanation / Answer
6. E. 0
7. C. 10
8. None of the option is correct. correct answer is infinite times.
Hint :-
public class Test {
public static void main (String[]args) {
int x = 3;
int y = 4;
switch (x + 3){
case 6: y = 0;break;
case 7: y = 1;break;
default: y += 1;}
System.out.println(y);
}
}
Output:-
0
public class Test {
public static void main (String[]args) {
int count = 0;
do {
System.out.println("Welcome to Java");
count++;
}while (count < 10);
}
}
Output:-
8. None of the option is correct. it will print infinite times.---->
public class Test {
public static void main (String[]args) {
int count = 0;
while (count < 10) {
System.out.println("Welcome to Java");
}
}
}