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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...