C# Questions and Answers – Data Types – Part 1

This blog post on the C# Questions and Answers – Data Types Part 1 focuses on C# multiple choice interview questions on data types.

C# Questions and Answers – Data Types – Part 1

1. Which of the below data types are value types ?
a. Array
b. String
c. Long
d. Integer

Answer : (c) and (d) Long and Integer are value types in C# whereas Array and String are reference types.

2. What is the default type of number without decimal points ?
a. Long Int
b. Unsigned Long
c. Int
d. Unsigned Int

Answer : (c) Int.

3. What is the range of values that is supported by float data type ?

Answer : 1.5 * 10 ^-45 to 3.4 * 10 ^38

4. What is the default value of the boolean datatype in C# ?

Answer : False

5. Which datatype from the below is a 8 byte integer ?
a. long
b. short
c. byte
d. integer

Answer : long

6. which datatype from the below is a 16 byte integer ?
a. long
b. int
c. decimal
d. short

Answer : decimal

7. How to convert an integer to hexadecimal number in C# ?

Answer : use the X format string as shown below.
Console.WriteLine(“{0:X}”, 100);

8. How do you find the difference between two dates in C# ?

Answer : You can find the Difference in terms if the TimeSpan as shown below.

DateTime d1 = new DateTime(2014,10,1);
DateTime d2 = new DateTime(2014,11,1);
TimeSpan differencedays = d2 – d1;
var diffDay = differencedays.Days.

9. What is the default datatype of a number with decimal points ?

Answer : double

10. Can Mod operator (%) be used with the float data types ?

Answer : No

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

Infragistics Webinar - How to Choose the Right Chart for Your Data ?
Infragistics is hosting a webinar on the topic "How to Choose the Right Chart for Your Data ?" on Ma...
C# Program to Generate Random Number
Introduction This program developed using C# , .NET Framework and Visual Studio demonstrates how to...
C# Program to swap two numbers without using temporary variable
Introduction This program in C# developed using .NET Framework and Visual Studio  will demonstrate ...