adplus-dvertising
frame-decoration

Question

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

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().

namespace CompSciBitsConsoleApplication
( 
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
    } 
} 
}

a.

1, 2, 3

b.

2, 3, 4

c.

3, 4

d.

4, 5

Posted under C# programming

Answer: (b).2, 3, 4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following statements are correct about the C#.NET code snippet given below? 1. To define a variable of type enum color in Main(), we should use the statement, color...

Similar Questions

Discover Related MCQs

Q. Which of the following statements is correct about an enum used in C#.NET?

Q. Choose the correct statement among the followings?

Q. Choose the keyword which declares the indexer?

Q. Choose the operator/operators which is/are not used to access the [] operator in indexers?

Q. Choose the correct statement among the following?

Q. Which among the following are the advantages of using indexers?

Q. Choose the correct statement about properties describing the indexers?

Q. Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?

Q. Choose the correct option among the following indexers which correctly allows to index in same way as an array?

Q. Choose the wrong statement about the properties used in C#.NET?

Q. Choose the statements which makes use of essential properties rather than making data member public in C#.NET?

Q. Where the properties can be declared?

Q. Select the modifiers which can be used with the properties?

Q. Choose the correct statements about write-only properties in C#.NET?

Q. Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail.Which of the follwing is the correct

Q. Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail.Which among the following is the correct solution to ensure this functionality?

Q. Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work.Which is the correct solution to ensure this functionality?

b.maths = 10;
Console.WriteLine(b.maths);

Q. If math class had add property with get and set accessors, then which of the following statements will work correctly?

Q. If the math class had add property with get accessors then which of the following statements will work correctly?

Q. Select the correct statement about properties of read and write in C#.NET?