1. Which of the following is a value type in C#?
Answer:
Explanation:
In C#, struct is a value type, whereas classes, strings, and delegates are reference types.
2. What is the size of a 'long' data type in C#?
Answer:
Explanation:
In C#, the 'long' data type is 64 bits, which equates to 8 bytes.
3. Which data type would you use in C# to store a large, precise decimal number?
Answer:
Explanation:
The 'decimal' data type in C# is used for storing large and precise decimal numbers, especially for financial calculations.
4. What is the range of the 'double' data type in C#?
Answer:
Explanation:
The 'double' data type in C# has a range of ±1.7E±308 with a precision of 15-16 digits.
5. What is the default value of a reference type in C#?
Answer:
Explanation:
In C#, the default value for reference types is null.
6. Which of the following is a non-nullable value type in C#?
Answer:
Explanation:
The 'float' data type is a non-nullable value type in C#. 'int?' and 'bool?' are nullable types, and 'string' is a reference type.
7. How many bytes are used by a 'char' in C#?
Answer:
Explanation:
In C#, a 'char' (character) is stored as a 2-byte Unicode character.
8. Which of the following data types is suitable for storing a single letter or character in C#?
Answer:
Explanation:
The 'Char' data type in C# is used for storing a single Unicode character.
9. In C#, what is the maximum value that an 'int' data type can hold?
Answer:
Explanation:
The 'int' data type in C# is a 32-bit signed integer, with a maximum value of 2,147,483,647.
10. What is the size of a 'bool' data type in C#?
Answer:
Explanation:
In C#, a 'bool' (boolean) data type occupies 1 byte.
11. Which data type in C# is best suited for storing a small integer value?
Answer:
Explanation:
The 'byte' data type in C# is an 8-bit unsigned integer, ideal for storing small integer values.
12. What is the default value of a struct in C#?
Answer:
Explanation:
In C#, the default value of a struct is the default value of each of its individual fields.
13. What is the difference between 'string' and 'String' in C#?
Answer:
Explanation:
In C#, 'string' is an alias for the 'System.String' class, and they are functionally equivalent.
14. In C#, what does the 'uint' data type represent?
Answer:
Explanation:
The 'uint' data type in C# represents an unsigned 32-bit integer, with a range from 0 to 4,294,967,295.
15. Which of the following data types has the smallest range in C#?
Answer:
Explanation:
The 'sbyte' data type in C# is an 8-bit signed integer with a range from -128 to 127, which is the smallest range among the options.
16. What is the purpose of the 'dynamic' data type in C#?
Answer:
Explanation:
The 'dynamic' data type in C# is used to store data of any type, with its type being determined and checked at runtime.
17. What is the output of the following C# code?
byte a = 255;
a++;
Answer:
Explanation:
In C#, the 'byte' data type wraps around on overflow. So, incrementing 255 will result in 0.
18. Which C# data type should be used for a variable that needs to hold a large number of true/false values?
Answer:
Explanation:
The 'BitArray' data type in C# is a collection that manages a compact array of bit values, suitable for handling a large number of true/false values.
19. What is the range of the 'float' data type in C#?
Answer:
Explanation:
The 'float' data type in C# is a 32-bit floating-point number with a range of ±1.5E−45 to ±3.4E38.
20. In C#, which data type is implicitly nullable?
Answer:
Explanation:
In C#, reference types like 'string' are implicitly nullable, meaning they can be assigned a null value.