Computer Applications
Consider the following code snippet:
int val = 2;
switch (val)
{
case 1: System.out.println("Case 1");
break;
case 2: System.out.println("Case 2");
break;
default: System.out.println("No match found");
break;
}
Which of the following statements is correct?
- case 1 will be executed.
- case 2 will be executed.
- default will be executed.
- both case 1 and 2 will be executed.
Related Questions
Consider the following code snippet:
if ( c > d) x = c; else x = d;
Choose the correct option if the code mentioned above is rewritten using the ternary operator:
if ((a > b) && (a > c)), then which of the following statements is true?
A sequence of statements enclosed between a pair of curly brackets is called
Which clause is optional in the switch statement?