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; }

- Online Exam Test Papers | - MCQs[multiple choice questions and answers ] | - Mock Test Papers | - Practice Papers | - Sample Test Papers |

Question:
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;
}

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

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

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

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


More MCQS Questions and answers

R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!