New! GraphQL.NET Cookbook by Senthil Kumar Balu

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

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.