C# (C Sharp) MCQs with answers Page - 6

Here, you will find a collection of MCQ questions on C# (C Sharp). Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. Which of the following statements are correct?
1. We can assign values of any type to variables of type object.
2. When a variable of a value type is converted to object, it is said to be unboxed.
3. When a variable of type object is converted to a value type, it is said to be boxed.
4. Boolean variable cannot have a value of null.
5. When a value type is boxed, an entirely new object must be allocated and constructed.

  • (A) 2,5
  • (B) 1,5
  • (C) 3,4
  • (D) 2,3

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified?

  • (A) float pi = 3.14F;
  • (B) #define pi 3.14F;
  • (C) const float pi = 3.14F;
  • (D) const float pi; pi = 3.14F;

A

Admin • 833.24K Points
Coach

Q. Which of the following can be used to terminate a while loop and transfer control outside the loop?
1. exit while
2. continue
3. exit statement
4. break
5. goto

  • (A) 1,3
  • (B) 2,4
  • (C) 3,5
  • (D) 4,5

A

Admin • 833.24K Points
Coach

Q. Which of the following statements are correct about the C#.NET code snippet given below?
if (age > 18 && no < 11) a = 25;
1. The condition no <11 will be evaluated only if age > 18 evaluates to True.
2. The statement a =25 will get executed if any one condition is True.
3. The condition no < 11will be evaluated only if age > 18 evaluates to False.
4. The statement a = 25 will get executed if both the conditions are True.
5. && is known as a short circuiting logical operator.

  • (A) 1,3
  • (B) 2,5
  • (C) 1,4,5,
  • (D) 3,4,5

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct output for the C#.NET code snippet
given below?

Code:
Console.WriteLine(13 / 2 + " " + 13 % 2);
  • (A) 6.5 1
  • (B) 6.5 0
  • (C) 6 0
  • (D) 6 1

A

Admin • 833.24K Points
Coach

Q. Which of the following statements are correct?
1. Instance members of a class can be accessed only through an object of that class.
2. A class can contain only instance data and instance member function.
3. All objects created from a class will occupy equal number of bytes in memory.
4. A class can contain Friend functions. 5. A class is a blueprint or a template according to which objects are created.

  • (A) 1,3,5
  • (B) 2,4
  • (C) 3,5
  • (D) 2,4,5

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to create an object of the
class Sample?
1. Sample s = new Sample();
2. Sample s;
3. Sample s; s =new Sample();
4. s = new Sample();

  • (A) 1,3
  • (B) 2,4
  • (C) 1,2,3
  • (D) 4,5

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is correct about constructors?

  • (A) If we provide a one-argument constructor then the compiler still provides a zero argument constructor.
  • (B) Overloaded constructors have the same name as the class name
  • (C) Overloaded constructors cannot use optional arguments.
  • (D) If we do not provide a constructor, then the compiler provides a zero-argument constructor.

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is correct?

  • (A) There is one garbage collector per program running in memory.
  • (B) There is one common garbage collector for all programs.
  • (C) An object is destroyed by the garbage collector when only one reference refers to it.
  • (D) We have to specifically run the garbage collector after executing Visual Studio.NET.

A

Admin • 833.24K Points
Coach

Q. Which of the following can be facilitated by the Inheritance
mechanism?
1. Use the existing functionality of base class.
2. Override the existing functionality of base class.
3. Implement new functionality in the derived class.
4. Implement polymorphic behaviour.
5. Implement containership.

  • (A) 1,2,3
  • (B) 3,4
  • (C) 2,4,5
  • (D) 3,5

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ