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.

In C#, what is the result of the expression 5 / 2?

  1. A. 2.5
  2. B. 2
  3. C. Compilation error
  4. D. None of the above
Report Error

What is the purpose of the 'is' keyword in C#?

  1. A. Checks if two objects are equal
  2. B. Compares two values
  3. C. Checks if an object is compatible with a type
  4. D. Checks if an object is null
Report Error

What is the correct way to declare a multi-dimensional array in C#?

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

Which data type is used to store true/false values in C#?

  1. A. bool
  2. B. boolean
  3. C. char
  4. D. int
Report Error

What is the purpose of the 'foreach' loop in C#?

  1. A. Performs a conditional iteration
  2. B. Terminates the loop
  3. C. Iterates over elements in a collection
  4. D. Executes a block of code repeatedly
Report Error

What is the default value of a reference type variable in C# if not explicitly initialized?

  1. A. 0
  2. B. FALSE
  3. C. TRUE
  4. D. Null
Report Error

What is the output of the following code: Console.WriteLine("10" + 5);

  1. A. Compilation error
  2. B. 10
  3. C. 105
  4. D. 15
Report Error

Which of the following is a valid way to declare a constant string in C#?

  1. A. MESSAGE const = "Hello"
  2. B. const string MESSAGE = "Hello"
  3. C. const MESSAGE = "Hello"
  4. D. None of the above
Report Error

What is the correct way to declare a floating-point variable with single precision in C#?

  1. A. Num float
  2. B. Var num
  3. C. float num
  4. D. double num
Report Error

What is the correct way 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

What is the default value of a boolean variable in C# if not explicitly initialized?

  1. A. 0
  2. B. Null
  3. C. FALSE
  4. D. TRUE
Report Error

What is the purpose of the 'static' keyword in C#?

  1. A. Initializes variables
  2. B. Declares constants
  3. C. Associates members with the class
  4. D. Defines methods
Report Error