Commerce

Basic Syntax And Data Types In C Sharp MCQs

Practice Basic Syntax And Data Types In C Sharp MCQs for competitive exams.

Basic Syntax And Data Types In C Sharp MCQs

Practice questions from this topic.

What is the correct syntax to define a multi-line comment in C#?

  1. A. -- This is a multi-line comment
  2. B. # This is a multi-line comment
  3. C. // This is a multi-line comment
  4. D. /* This is a multi-line comment */
Report Error

Which of the following is a valid way to represent the number 1000 in C#?

  1. A. 1 000
  2. B. 10_00
  3. C. 1000
  4. D. None of the above
Report Error

What is the purpose of the 'break' statement in a loop in C#?

  1. A. Continues to the next loop
  2. B. Terminates the loop
  3. C. Initializes the loop
  4. D. None of the above
Report Error

What is the correct way to declare an array of integers in C#?

  1. A. numbers[] int
  2. B. array numbers
  3. C. int[] numbers
  4. D. numbers = int[]
Report Error

Which of the following is a valid way to declare a character variable in C#?

  1. A. var letter = 'A'
  2. B. character letter = 'A'
  3. C. char letter = "A"
  4. D. char letter = 'A'
Report Error

What is the correct syntax to create a multi-line comment in C#?

  1. A. /* This is a multi-line comment */
  2. B. // This is a multi-line comment
  3. C. # This is a multi-line comment
  4. D. -- This is a multi-line comment
Report Error

What is the correct way to declare a string variable in C#?

  1. A. string = str
  2. B. var str
  3. C. string str
  4. D. str string
Report Error

Which data type is used to store floating-point numbers with a larger range and precision?

  1. A. decimal
  2. B. double
  3. C. long
  4. D. None of the above
Report Error

What does the 'using' directive do in C#?

  1. A. Defines classes
  2. B. Declares variables
  3. C. Imports namespaces
  4. D. Handles exceptions
Report Error

What is the correct syntax to declare a constant in C#?

  1. A. constant MAX_VALUE = 100
  2. B. MAX_VALUE = 100
  3. C. int MAX_VALUE = 100
  4. D. const int MAX_VALUE = 100
Report Error

Which of the following is a valid C# statement?

  1. A. Console.WriteLine("Hello, World!")
  2. B. print("Hello, World!")
  3. C. System.out.println("Hello, World!")
  4. D. echo "Hello, World!"
Report Error

What is the default value of an integer variable in C# if not explicitly initialized?

  1. A. 1
  2. B. null
  3. C. -1
  4. D. 0
Report Error