Control Instructions

Q1:
Which of the following statements is correct about the C#.NET code snippet given below?
int i, j, id = 0; switch (id)
{ 
    case i:
        Console.WriteLine('I am in Case i');
        break; 
    
    case j:
        Console.WriteLine('I am in Case j');
        break;
}

A
The compiler will report case i and case j as errors since variables cannot be used in cases.

B
Compiler will report an error since there is no default case in the switch case statement.

C The code snippet prints the result as "I am in Case i"".

D The code snippet prints the result as "I am in Case j".

E There is no error in the code snippet.

ANS:A -

The compiler will report case i and case j as errors since variables cannot be used in cases.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.