CPP225 Enumerations and Structures Quiz
16 Questions
1 Views
3.5 Stars

CPP225 Enumerations and Structures Quiz

Created by
@RedeemingDaffodil

Questions and Answers

What is an enumeration in object-oriented programming?

A predefined data type with a set of name-value pairs

What is the default initial value of the first element in an enumeration?

0

In an enumeration, how can you change the initial value of the elements?

Specify the desired initial value after the element name

What is the default storage type used to hold the values of an enumeration?

<p>System.Int32</p> Signup and view all the answers

In an enumeration, do the numerical values need to be unique?

<p>No, they can be duplicated for multiple elements</p> Signup and view all the answers

Which of the following best describes the purpose of using an enumeration?

<p>To create a set of symbolic names mapping to known numerical values</p> Signup and view all the answers

What does the ToString() method return for an enumeration variable?

<p>The string name of the current enumeration’s value</p> Signup and view all the answers

Which method is used to obtain the data type used to store the values of an enumerated type?

<p>Enum.GetUnderlyingType()</p> Signup and view all the answers

How do you declare an enum variable in C#?

<p>Color myColor = Blue;</p> Signup and view all the answers

What happens if you forget to scope the enum name when assigning a value to an enum variable?

<p>It will result in a compile error</p> Signup and view all the answers

What is the purpose of changing the underlying type of an enumeration?

<p>To decrease the memory usage of the enumeration variable</p> Signup and view all the answers

What is the result if you set an enum variable to a value not defined directly by the enumerated type?

<p>It issues a compile error</p> Signup and view all the answers

How can you obtain the numerical value of an enumeration variable?

<p>(int)myColor</p> Signup and view all the answers

Which class provides methods to interrogate and transform a given enumeration?

<p>.NET.System.Enum</p> Signup and view all the answers

In which case will forgetting to scope the enum name result in an error?

<p>When assigning a value to an enum variable</p> Signup and view all the answers

What does System.Type represent in .NET?

<p>.NET metadata description</p> Signup and view all the answers

More Quizzes Like This

Use Quizgecko on...
Browser
Browser