C# Questions and Answers – Data Types Part 2

This blog post on the C# Questions and Answers – Data Types Part 2 focuses on C# multiple choice interview questions on the data types in C# like char , integer etc.

C# Questions and Answers – Data Types Part 2

1. What is Size of the char data type in C# ?
a. 8 bit
b. 12 bit
c. 16 bit
d. 20 bit

Answer : (C) 16 bit

2. Which method of String is used to compare two strings with each other by length ?
a. CompareTo
b. Compare
c. Copy
d. Concat

Answer: (b) The string.Compare method can be used to compare two strings.

3. What are the different ways in which a variable name cannot be started with in C# ?

Answer : The valid variable name cannot start with a number or special symbol . Underscore is an exemption.

4. What will be the output of the following program ?

int a = 7 , b = 2;
int c = a/b;

a. 3.5
b. 3
c. Runtime Error
d. Compiler Error.

Answer : ( b ) 3

5. Which one of the below is a 2 byte integer in C# ?
a. short
b. int
c. unsigned int
d. long

Answer : (a) short

6. which data type is ideally used for calculation of currency values in C# ?
a. double
b. float
c. decimal
d. money

Answer : © decimal

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


x

Interesting BlogPosts to read

How to perform Shallow Copy in C# ? by @abundantcode
To perform Shallow copy in C# , you can use the this.MemberwiseClone() method. How to perform Shall...
How to add entries to ResourceDirectory in WPF using C# ?
Below is a sample code snippet demonstrating how the entries can be added to the ResourceDirectory i...
Replacing Multiple spaces with single space in C#
Are you looking at an sample demonstrating the usage of the regular expression to replace multiple s...