Home / C# Programming / Control Instructions - c# :: Discussion

Discussion :: Control Instructions - c#

  1. Which of the following statements is correct about the C#.NET code snippet given below?

     switch (id)
     {   
       case 6:       
          grp = "Grp B";      
          break;       
       
        case 13:      
          grp = "Grp D";   
          break;        
       
         case 1:     
          grp = "Grp A";     
          break;          
    
         case ls > 20:       
           grp = "Grp E";        
           break ;        
    
          case Else:     
            grp = "Grp F";     
            break; 
    }
    

  2. A.

    Compiler will report an error in case ls > 20 as well as in case Else.

    B.

    There is no error in this switch case statement.

    C.

    Compiler will report an error only in case Else.

    D.

    Compiler will report an error as there is no default case.

    E.

    The order of the first three cases should be case 1, case 6, case 13 (ascending).

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    No answer description available for this question.


Be The First To Comment