Enumerations Questions
Practice Enumerations MCQs with answers and explanations. Page 1 of 1.
Category
C# Programming
Topic
Enumerations
Page
1 / 1
Mode
Practice
Questions
Open any question to view the answer and explanation.
C#.NET enums — analyze the following declaration:
enum color : byte
{
red = 500,
green = 1000,
blue = 1500
}
Which statement about this code is correct?
Open
View answer
C#.NET enums — given:
enum per
{
married,
unmarried,
divorced,
spinster
}
per.married = 10;
Console.WriteLine(per.unmarried);
Which statement describes the program's behavior?
Open
View answer
C#.NET enums — what is printed by:
enum color
{
red,
green,
blue
}
color c;
c = color.red;
Console.WriteLine(c);
Open
View answer
C#.NET Enums and reflection: what will this program print for the first enum name?
enum color
{
red,
green,
blue
}
color c = color.red;
Type t;
t = c.GetType();
string[] str;
str = Enum.GetNames(t);
Console.WriteLine(str[0]);
Open
View answer
C#.NET enums with explicit and implicit values: what integers are printed?
enum color : int
{
red,
green,
blue = 5,
cyan,
magenta = 10,
yellow
}
Console.Write((int)color.green + ", ");
Console.Write((int)color.yellow);
Open
View answer
C#.NET enum fundamentals: identify the correct facts about the enum keyword and the System.Enum class.
Open
View answer
C#.NET enum with negative starting value: what integers are printed?
enum color : int
{
red = -3,
green,
blue
}
Console.Write((int)color.red + ", ");
Console.Write((int)color.green + ", ");
Console.Write((int)color.blue);
Open
View answer
C#.NET enums: choose all correct placement and typing rules.
Open
View answer
C#.NET enum category: is an enum a value type or a reference type?
Open
View answer
C#.NET accessibility of enums: is an enum declared inside a class, struct, namespace, or interface automatically public?
Open
View answer
C#.NET enum placement and accessibility: choose the true statement.
Open
View answer
C#.NET enums: select all correct statements about their nature and printing behavior.
Open
View answer
C#.NET enums: which underlying datatype is <em>not</em> permitted for an enum?
Open
View answer
C#.NET Enums — identify the correct statement about default values and member rules.
Consider general behavior of enum members in C#.NET (underlying integral types, default starting value, naming rules, and assignment constraints). Choose the single correct statement from the options below.
Open
View answer
C#.NET Enums — determine what happens when enum members are initialized with variables.
Given:
int a = 10;
int b = 20;
int c = 30;
enum color : byte { red = a, green = b, blue = c }
Open
View answer
C#.NET — working with private enums in classes.
Given a private enum declared inside class Sample, determine how it can be accessed in Main() of another class.
Open
View answer
C#.NET — Can an enum be declared inside class, struct, namespace, or interface?
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.