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

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. In C#, a single-line comment starts with ___.

  • (A) Two forward slashes (//)
  • (B) Two backward slashes (\)
  • (C) A hash character (#)
  • (D) A dollar character ($)

A

Admin • 833.24K Points
Coach

Q. In C#, the multi-line comments placed within the ___.

  • (A) // and //
  • (B) \ and //
  • (C) <!-- and -->
  • (D) /* and */

A

Admin • 833.24K Points
Coach

Q. What is the correct syntax to declare a variable in C#?

  • (A) type variableName = value;
  • (B) type variableName;
  • (C) variableName as type = value;
  • (D) Both A and B.

A

Admin • 833.24K Points
Coach

Q. Which data type is used to store text value in C#?

  • (A) text
  • (B) txt
  • (C) string
  • (D) str

A

Admin • 833.24K Points
Coach

Q. Which C# keyword is used to define a constant?

  • (A) define
  • (B) fixed
  • (C) constant
  • (D) const

A

Admin • 833.24K Points
Coach

Q. What is the correct syntax to define a C# constant?

  • (A) const type constant_name;
  • (B) const type constant_name = value;
  • (C) const constant_name as type;
  • (D) const constant_name as type = value;

A

Admin • 833.24K Points
Coach

Q. Which is not a valid C# data type?

  • (A) long
  • (B) int
  • (C) float
  • (D) complex

A

Admin • 833.24K Points
Coach

Q. Which is the correct order for implicit type conversion to convert a smaller to a larger type in C#?

  • (A) char -> int -> long -> float -> double
  • (B) bool -> char -> int -> long -> float -> double
  • (C) char -> int -> float -> long -> double
  • (D) bool -> char -> int -> long -> double -> float

A

Admin • 833.24K Points
Coach

Q. Which is the correct order for explicit type conversion to convert a larger to a smaller type in C#?

  • (A) double -> float -> long -> int -> char -> bool
  • (B) double -> float -> long -> int -> char
  • (C) float -> double -> long -> int -> char
  • (D) float -> double -> long -> int -> char -> bool

A

Admin • 833.24K Points
Coach

Q. Which is the correct C# statement to convert a float value to int explicitly?

  • (A) int_variable = (int) float_variable;
  • (B) int_variable = float_variable;
  • (C) int_variable = (int) (float_variable);
  • (D) int_variable = int *float_variable);

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