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

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. What will be the output of the following C# code?

Code:
using System;

class Program {
  public static void Main() {
    int i = 10;
    Console.WriteLine(i++);
  }
}
  • (A) 10
  • (B) 11
  • (C) 12
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which is the correct for() statement to run an infinite loop?

  • (A) for(;;)
  • (B) for(;;);
  • (C) for(;;)
  • (D) for(1;1;1)

A

Admin • 833.24K Points
Coach

Q. Which C# keyword is used to coming out from the loop?

  • (A) break
  • (B) continue
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is String in C# meant for?

  • (A) A variable
  • (B) A Class
  • (C) An Array
  • (D) An object

A

Admin • 833.24K Points
Coach

Q. Which is the base class of the String() Constructor?

  • (A) String
  • (B) System.IO.String
  • (C) System.Strings
  • (D) System.String

A

Admin • 833.24K Points
Coach

Q. Which String class operator is used to determine whether two specified strings have different values?

  • (A) !=
  • (B) !
  • (C) ~
  • (D) /

A

Admin • 833.24K Points
Coach

Q. Except == operator, which methods can be used to compare two strings?

  • (A) Equal()
  • (B) Compare()
  • (C) Both A and B
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Which is the correct method to convert given string in uppercase?

  • (A) Upper()
  • (B) ToUpper()
  • (C) Upr()
  • (D) ToUpr()

A

Admin • 833.24K Points
Coach

Q. What is String.Length in C#?

  • (A) Property
  • (B) Method
  • (C) Constructor
  • (D) Both A and B

A

Admin • 833.24K Points
Coach

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

Code:
using System;

class Program {
  static void Main(string[] args) {
    String s1 = "Hello";
    String s2 = "IncludeHelp";
    String s3 = s1;
    Console.WriteLine(s1.Equals(s3) + "  " + s2.CompareTo(s1));
  }
}
  • (A) Error
  • (B) True True
  • (C) True False
  • (D) True 1

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