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

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 {
  static void Main(string[] args) {
    String str = "Hello";
    Console.WriteLine(str.Length);

  }
}
  • (A) 5
  • (B) 6
  • (C) 7
  • (D) 4

A

Admin • 833.24K Points
Coach

Q. To declare an array, define the variable type with ___.

  • (A) Square brackets []
  • (B) Curly brackets {}
  • (C) Round brackets ()
  • (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 {
  class Program {
    static void Main(string[] args) {
      string[] mobiles = { "iPhone", "Samsung", "Vivo"};
      Console.WriteLine(mobiles);
    }
  }
}
  • (A) "iPhone", "Samsung", "Vivo"
  • (B) {"iPhone", "Samsung", "Vivo"}
  • (C) string[]
  • (D) System.String[]

A

Admin • 833.24K Points
Coach

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

Code:
using System;

namespace MyApplication {
  class Program {
    static void Main(string[] args) {
      string[] mobiles = {"iPhone", "Samsung", "Vivo"};
      Console.WriteLine(mobiles[-1]);
    }
  }
}
  • (A) None
  • (B) Warning
  • (C) Exception
  • (D) System.String[]

A

Admin • 833.24K Points
Coach

Q. Which array property is used to get the total number of elements in C#?

  • (A) Len
  • (B) Length
  • (C) Elements
  • (D) MaxLen

A

Admin • 833.24K Points
Coach

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

Code:
using System;

namespace MyApplication {
  class Program {
    static void Main(string[] args) {
      string[] mobiles = {"iPhone", "Samsung", "Vivo"};
      Console.WriteLine(mobiles[0] + mobiles[2]);
    }
  }
}
  • (A) iPhoneVivo
  • (B) iPhone+Vivo
  • (C) Exception
  • (D) iPhone Vivo

A

Admin • 833.24K Points
Coach

Q. Which array method is used to sort an array alphabetically or in an ascending order in C#?

  • (A) sort()
  • (B) sorting()
  • (C) Sort()
  • (D) Sorting()

A

Admin • 833.24K Points
Coach

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

Code:
1
  • (A) 1
  • (B) 2
  • (C) 5
  • (D) Runtime Error

A

Admin • 833.24K Points
Coach

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

Code:
using System;

namespace MyApplication {
  class Program {
    static void Main(string[] args) {
      int[,] ARR = {{1,2},{3,4}};
      Console.WriteLine(ARR.GetLength(0)+","+ARR.GetLength(1));
    }
  }
}
  • (A) 4,4
  • (B) 2,2
  • (C) Compilation Error
  • (D) Runtime Error

A

Admin • 833.24K Points
Coach

Q. Which of the correct syntax to declare an array with 2 rows and 3 columns in C#?

  • (A) int arr[2][3] = new int[2][3];
  • (B) int arr[2,3] = new int[2,3];
  • (C) int[,] arr = new int[2,3];
  • (D) int [,]arr = new [2,3]int;

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