Enumerations

Q1: Which of the following statements are correct about the C#.NET code snippet given below?
namespace AptitudeCrackConsoleApplication
( 
class Sample
{ 
    private enum color : int
    { 
        red, 
        green, 
        blue
    }
    public void fun()
    {
        Console.WriteLine(color.red); 
    }
}
class Program
{ 
    static void Main(string[ ] args)
    { 
        // Use enum color here
    } 
} 
}
  1. To define a variable of type enum color in Main(), we should use the statement, color c; .
  2. enum color being private it cannot be used in Main().
  3. We must declare enum color as public to be able to use it outside the class Sample.
  4. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; .
  5. We must declare private enum color outside the class to be able to use it in Main().

A 1, 2, 3

B 2, 3, 4

C 3, 4

D 4, 5

ANS:A - 1, 2, 3

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.