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

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 keyword is used to define a class in C#?

  • (A) Class
  • (B) class
  • (C) System.Class
  • (D) OOPS.class

A

Admin • 833.24K Points
Coach

Q. Which is the correct way to declare an object of the class in C#?

  • (A) Class_Name Object_Name = new Class_Name();
  • (B) Class_Name Object_Name;
  • (C) new Object_Name as Class_Name();
  • (D) Both A and B

A

Admin • 833.24K Points
Coach

Q. Which operator is used to access variables/fields inside a class in C#?

  • (A) Arrow Operator (->)
  • (B) Dot Operator (.)
  • (C) Greater Than (>)
  • (D) Dot and Greater Than (.>)

A

Admin • 833.24K Points
Coach

Q. Which is not a type of constructor in C#?

  • (A) Static Constructor
  • (B) Private Constructor
  • (C) Public Constructor
  • (D) Parameterized Constructor

A

Admin • 833.24K Points
Coach

Q. How many types of access modifiers in C#?

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

A

Admin • 833.24K Points
Coach

Q. What does the access modifier do in C#?

  • (A) To maintain the syntax
  • (B) To define a variable inside the class
  • (C) To access the variables defined inside the class
  • (D) To control the visibility of class members

A

Admin • 833.24K Points
Coach

Q. The internal access modifier is used for ___.

  • (A) Types and type members
  • (B) Defining a field that can be accessed in all classes
  • (C) Defining a field that can be accessed in inherited classes
  • (D) All of the above

A

Admin • 833.24K Points
Coach

Q. The protected access modifier defines a member that can be accessible within ___.

  • (A) its class and all other classes
  • (B) its class and by derived class instances
  • (C) its class only
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which C# concept has the capability of an object to take number of different forms and hence display behaviour as accordingly?

  • (A) Polymorphism
  • (B) Encapsulation
  • (C) Abstraction
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C# code?

Code:
using System;

namespace MyApplication {
  public class Class1 {
    public static int x = 10;

  }
  public class Class2: Class1 {
    public static int x = 20;
    static void Main(string[] args) {
      Console.WriteLine(x + ", " + Class1.x);
    }
  }
}
  • (A) 20, 20
  • (B) 10, 10
  • (C) 20, 10
  • (D) Exception