98-372 · Question #90
Which of the following are value types? Each correct answer represents a complete solution. Choose all that apply.
The correct answer is A. double C. bool D. long F. char. The types bool, char, double, and long are value types. A value type is a variable that contains data values, which are stored in a memory storage area known as the stack. Following are the three general value types: Built-in Types: These value types are the base types provided b
Question
Which of the following are value types? Each correct answer represents a complete solution. Choose all that apply.
Options
- Adouble
- Binterface
- Cbool
- Dlong
- Estring
- Fchar
How the community answered
(55 responses)- A82% (45)
- B13% (7)
- E5% (3)
Explanation
The types bool, char, double, and long are value types. A value type is a variable that contains data values, which are stored in a memory storage area known as the stack. Following are the three general value types: Built-in Types: These value types are the base types provided by the .NET Framework, on the basis of which other value types are built. Built-in value types can be either numeric or non- numeric types. Some of the numeric built-in value types are sbyte, byte, int, float, double, etc. Some of the non-numeric built-in value types are char, bool, and date. User-defined Types: These value types are known as structures or structs that are defined by users. The keyword struct is used for the user-defined value types in C# language specification. These user-defined types are used to create more than one variable encapsulated in a small group of related data. The struct is a combined unit of various data types that are grouped into a single unit. These different data types are known as members. Members can be constructors, constants, fields, methods, properties, events, operators, indexers, etc. Enumerations: These provide symbols to a fixed set of related data values. The keyword used in C# for enumerations is enum. These enumerations improve code readability to users. Generally, the sequence of elements starts from zero. Note: When one value type variable is assigned to another variable, data is also copied from one variable to another variable. Hence, the same data is stored in two different locations on the stack Answer: B and E are incorrect. The types interface and string are reference types.
Topics
Community Discussion
No community discussion yet for this question.