C# MCQ Assignment
Question 1:
Which of the following is the correct syntax to declare a variable in C#?
int 4value;int value;int value=4;int value=
Correct Answer: 2, 3
Question 2:
Which of the following is the entry point of a C# program?
Main()Start()Program()Begin()
Correct Answer: 1
Question 3:
Which keyword is used to define an interface in C#?
interfaceclassstructenum
Correct Answer: 1
Question 4:
Which of the following is NOT a value type in C#?
intfloatdoublestring
Correct Answer: 4
Question 5:
Which of the following access modifiers allows a class member to be accessed from within the same assembly, but not from another assembly?
publicprivateprotectedinternal
Correct Answer: 4
Question 6:
What is the size of an int data type in C#?
- 2 bytes
- 4 bytes
- 8 bytes
- 16 bytes
Correct Answer: 2
Question 7:
Which of the following statements is used to handle exceptions in C#?
try-catchcatch-trytry-errorhandle-exception
Correct Answer: 1
Question 8:
What will be the output of the following code snippet?
csharpCopy codeint a = 10;
int b = 20;
int c = a + b;
Console.WriteLine(c);
- 10
- 20
- 30
- Compilation Error
Correct Answer: 3
Question 9:
Which of the following is used to read a line of text from the console in C#?
Console.ReadLine()Console.Read()Console.ReadText()Console.ReadKey()
Correct Answer: 1
Question 10:
Which of the following statements correctly defines a method in C#?
void MyMethod(int a, int b) { }void MyMethod(int a; int b) { }void MyMethod(int a, int b);void MyMethod(int a, int b)
Correct Answer: 1