# C# Programming MCQ - Multiple Choice Question and Answer

## C# Programming MCQ with detailed explanation for interview, entrance and competitive exams. Explanation are given for understanding.

Question No : 1
Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74

int a = 12;float b = 6.2f;int c;c = a / b + a * b;Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = a / convert.ToInt32(b) + a * b;Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = a / convert.ToInt32(b) + a * convert.ToInt32(b);Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = convert.ToInt32(a / b + a * b);Console.WriteLine(c);

Question No : 2
How many Bytes are stored by Long Datatype in C# .net?

8
4
2
1

Question No : 3
Choose “.NET class” name from which datatype “UInt” is derived ?

System.Int16
System.UInt32
System.UInt64
System.UInt16

Question No : 4
Correct Declaration of Values to variables a and b?

int a = 32, b = 40.6;
int a = 42; b = 40;
int a = 32; int b = 40;
int a = b = 42;

Question No : 5
Select error in the given program :

Static Void Main(String[] args){const int m = 100;int n = 10;const int k = n / 5 * 100 * n ;Console.WriteLine(m * k);Console.ReadLine();}

‘k’ should not be declared constant
Expression assigned to ‘k’ should be constant in nature
Expression (m * k) is invalid
‘m ‘ is declared in invalid format

Question No : 6
Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74 ?

int a = 12;float b = 6.2f;int c;c = a / b + a * b;Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = a / convert.ToInt32(b) + a * b;Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = a / convert.ToInt32(b) + a * convert.ToInt32(b);Console.WriteLine(c);
int a = 12;float b = 6.2f;int c;c = convert.ToInt32(a / b + a * b);Console.WriteLine(c);

Question No : 7
Arrange the following datatype in order of increasing magnitude sbyte, short, long, int.

long < short < int < sbyte
sbyte < short < int < long
short < sbyte < int < long
short < int < sbyte < long