CommerceBasic 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#?
- A. -- This is a multi-line comment
- B. # This is a multi-line comment
- C. // This is a multi-line comment
- D. /* This is a multi-line comment */
Correct Answer: D
Which of the following is a valid way to represent the number 1000 in C#?
- A. 1 000
- B. 10_00
- C. 1000
- D. None of the above
Correct Answer: C
What is the purpose of the 'break' statement in a loop in C#?
- A. Continues to the next loop
- B. Terminates the loop
- C. Initializes the loop
- D. None of the above
Correct Answer: B
What is the correct way to declare an array of integers in C#?
- A. numbers[] int
- B. array numbers
- C. int[] numbers
- D. numbers = int[]
Correct Answer: C
Which of the following is a valid way to declare a character variable in C#?
- A. var letter = 'A'
- B. character letter = 'A'
- C. char letter = "A"
- D. char letter = 'A'
Correct Answer: D
What is the correct syntax to create a multi-line comment in C#?
- A. /* This is a multi-line comment */
- B. // This is a multi-line comment
- C. # This is a multi-line comment
- D. -- This is a multi-line comment
Correct Answer: A
What is the correct way to declare a string variable in C#?
- A. string = str
- B. var str
- C. string str
- D. str string
Correct Answer: C
Which data type is used to store floating-point numbers with a larger range and precision?
- A. decimal
- B. double
- C. long
- D. None of the above
Correct Answer: B
What does the 'using' directive do in C#?
- A. Defines classes
- B. Declares variables
- C. Imports namespaces
- D. Handles exceptions
Correct Answer: C
What is the correct syntax to declare a constant in C#?
- A. constant MAX_VALUE = 100
- B. MAX_VALUE = 100
- C. int MAX_VALUE = 100
- D. const int MAX_VALUE = 100
Correct Answer: D
Which of the following is a valid C# statement?
- A. Console.WriteLine("Hello, World!")
- B. print("Hello, World!")
- C. System.out.println("Hello, World!")
- D. echo "Hello, World!"
Correct Answer: A
What is the default value of an integer variable in C# if not explicitly initialized?
- A. 1
- B. null
- C. -1
- D. 0
Correct Answer: D