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

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 • 832.27K Points
Coach

Q. Which one of the following statements is correct?

  • (A) Array elements can be of integer type only.
  • (B) The rank of an Array is the total number of elements it can contain
  • (C) The length of an Array is the number of dimensions in the Array.
  • (D) The default value of numeric array elements is zero.

A

Admin • 832.27K Points
Coach

Q. Which of the following statements are correct about arrays used in C#.NET?
1. Arrays can be rectangular or jagged.
2. Rectangular arrays have similar rows stored in adjacent memory locations.
3. Jagged arrays do not have an access to the methods of System.Array Class.
4. Rectangular arrays do not have an access to the methods of System.Array
Class.
5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

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

A

Admin • 832.27K Points
Coach

Q. Which of the following statements are correct?
1. A struct can contain properties.
2. A struct can contain constructors.
3. A struct can contain protected data members.
4. A struct cannot contain methods.
5. A struct cannot contain constants.

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

A

Admin • 832.27K Points
Coach

Q. Which of the following will be the correct output for the C#.NET code snippet given below? String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2);

  • (A) ARE
  • (B) CRE
  • (C) CR
  • (D) REA

A

Admin • 832.27K Points
Coach

Q. If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?

  • (A) s1 is s2
  • (B) s1=s2
  • (C) s1==s2
  • (D) s1.Equals(s2)

A

Admin • 832.27K Points
Coach

Q. Which of the following statements is correct about an Exception?

  • (A) It occurs during compilation.
  • (B) It occurs during linking.
  • (C) It occurs at run-time.
  • (D) It occurs during Just-In-Time compilation.

A

Admin • 832.27K Points
Coach

Q. Which of the following statements are correct about exception handling in C#.NET?
1 If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception.
2 No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed.
3 A program can contain multiple finally clauses.
4 A finally clause is written outside the try block.
5 Finally clause is used to perform cleanup operations like closing the network/database connections.

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

A

Admin • 832.27K Points
Coach

Q. ______ parameters are used to pass results back to the calling method.

  • (A) Input
  • (B) Reference
  • (C) Value
  • (D) Output

A

Admin • 832.27K Points
Coach

Q. The formal-parameter-list is always enclosed in _______.

  • (A) Square
  • (B) Semicolon
  • (C) Parenthesis
  • (D) Colon

A

Admin • 832.27K Points
Coach

Q. _______ variables are visible only in the block they are declared.

  • (A) System
  • (B) Global
  • (C) Local
  • (D) Console