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

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...