A and B are out because Charlie knows his problem is he is not going to finish in time. D is out because he hasn't talked to his manager yet. so only choice left is C. decide if he should talk to his manager about the problem he now knows
Answer:
public class SwitchCase {
public static void main(String[] args) {
int num = 0;
int a = 10, b = 20, c = 20, d = 30, x = 40;
switch (num){
case 102: a += 1;
case 103: a += 1;
case 104: a += 1;
case 105: a += 1;
break;
case 208: b += 1; x = 8;
break;
case 209: c = c * 3;
case 210: c = c * 3;
break;
default: d += 1004;
}
}
}
Explanation:
- Given above is the equivalent code using Switch case in Java
- The switch case test multiple levels of conditions and can easily replace the uses of several if....elseif.....else statements.
- When using a switch, each condition is treated as a separate case followed by a full colon and the the statement to execute if the case is true.
- The default statement handles the final else when all the other coditions are false
In most languages. Primitive data types ( char, int, float, bool, maybe string ) are usually passed by value, but compound data types are passed by reference, so you're not working on a copy but on the original.
Explanation:
The second for loop does 1 of 4 iterations for every 1 of 5 iterations of the parent loop. meaning it is 4 x 5 which is 20.