Question: 1. Given the following code, the output is __. int n = 5; if (n < 5) { n = 6; } if (n >=5)
1. Given the following code, the output is __. int n = 5; if (n < 5) { n = 6; } if (n >=5) { n = 7; } if (n > 5) { n = 4; } if (n <= 5) { n = 3; } System.out.println(n); A. 3 B. 4 C. 5 D. 6 E. 7 2. Given the following code, the output is __. int n = 5; if (n < 5) { n = 6; } else if (n >=5) { n = 7; } else if (n > 5) { n = 4; } else { n = 3; } System.out.println(n); A. 3 B. 4 C. 5 D. 6 E. 7 3. Given the following code, the output is __. int n = 5; if (n < 5)
{ n = 6; if (n >=5) { n = 7; } } else { if (n > 5) { n = 4; } else { n = 3; } } System.out.println(n); A. 3 B. 4 C. 5 D. 6 E. 7 4. Given the following code, the output is __. int x = 11; if (x > 4 && x < 7) { x = 19; } else { x = 5; } System.out.println(x); A. 11 B. 4 C. 7 D. 19 E. 5 5. Given the following code, the output is __. public class Sample { public static void main(String[] args) { int x = 5; if (x < 6) { x++; } else { x--; } if (x > 4) { x++; } else { x--; } System.out.println(x); } } A. 3 B. 4 C. 5 D. 6 E. 7 6. Given the following code, the output is __. char c = 'B'; switch (c) { case 'A': c= 'K'; case 'B': c = 'E';
case 'C': c = 'Q'; case 'D': c = 'H'; default: c = 'M'; } System.out.println(c); A. E B. Q C. M D. H E. K 7. Given the following code, the output is __. char c = 'B'; switch (c) { case 'A': c= 'K'; case 'B': c = 'E'; break; case 'C': c = 'Q'; case 'D': c = 'H'; break; default: c = 'M'; } System.out.println(c); A. E B. Q C. M D. H E. K 8. Given the following code, the output is __. int n = 19; char c = ' '; switch (n%4) { case 0: c= 'K'; break; case 1: c = 'E'; break; case 2: c = 'Q'; break; case 3: c = 'H'; break; default: c = 'M'; break; } System.out.println(c); A. E B. Q C. M D. H E. K 9. Given the following code, which is the correct way to define case label using the one of the enum type? int n = 0; ....... public enum Color { RED, GREEN, BLUE, YELLOW } A. case red: n = 16;
B. case 'GREEN': n = 17; C. case BLUE: n = 18; D. case "YELLO": n = 19; E. case Color.red: n = 20; 10. Given the following code, the output is __. String season = ""; int n = 0; switch (season) { case "Spring": n = 16; break; case "Summer": n = 17; break; case "Fall": n = 18; break; case "Winter": n = 19; break; default: n = 20; break; } System.out.println(n); A. 16 B. 17 C. 18 D. 19 E. 20
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
