C#

C# MCQ Assignment

C# MCQ Assignment

Question 1:

Which of the following is the correct syntax to declare a variable in C#?

  1. int 4value;
  2. int value;
  3. int value=4;
  4. int value=

Correct Answer: 2, 3

Question 2:

Which of the following is the entry point of a C# program?

  1. Main()
  2. Start()
  3. Program()
  4. Begin()

Correct Answer: 1

Question 3:

Which keyword is used to define an interface in C#?

  1. interface
  2. class
  3. struct
  4. enum

Correct Answer: 1

Question 4:

Which of the following is NOT a value type in C#?

  1. int
  2. float
  3. double
  4. string

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?

  1. public
  2. private
  3. protected
  4. internal

Correct Answer: 4

Question 6:

What is the size of an int data type in C#?

  1. 2 bytes
  2. 4 bytes
  3. 8 bytes
  4. 16 bytes

Correct Answer: 2

Question 7:

Which of the following statements is used to handle exceptions in C#?

  1. try-catch
  2. catch-try
  3. try-error
  4. handle-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);
  1. 10
  2. 20
  3. 30
  4. Compilation Error

Correct Answer: 3

Question 9:

Which of the following is used to read a line of text from the console in C#?

  1. Console.ReadLine()
  2. Console.Read()
  3. Console.ReadText()
  4. Console.ReadKey()

Correct Answer: 1

Question 10:

Which of the following statements correctly defines a method in C#?

  1. void MyMethod(int a, int b) { }
  2. void MyMethod(int a; int b) { }
  3. void MyMethod(int a, int b);
  4. void MyMethod(int a, int b)

Correct Answer: 1

You may also like...

Leave a Reply

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