Commerce

Variables And Constants In C Sharp MCQs

Practice Variables And Constants In C Sharp MCQs for competitive exams.

Variables And Constants In C Sharp MCQs

Practice questions from this topic.

What is the correct way to declare a variable without assigning a value in C#?

  1. A. num = int
  2. B. num int
  3. C. var num
  4. D. int num
Report Error

In C#, what is the default value of a boolean variable if not initialized explicitly?

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

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

  1. A. To make a variable constant
  2. B. To specify a data type that can change during runtime
  3. C. To make a variable accessible outside its class
  4. D. To specify a data type to be determined at runtime
Report Error

In C#, which keyword is used to declare a variable that cannot be modified once it is assigned a value?

  1. A. readonly
  2. B. static
  3. C. const
  4. D. volatile
Report Error

What is the data type of the following variable declaration: var name = "John";

  1. A. object
  2. B. string
  3. C. int
  4. D. None of the above
Report Error

Which of the following is a valid variable name in C#?

  1. A. 123variable
  2. B. _variable
  3. C. myVariable
  4. D. Variable!
Report Error

What is the correct way to declare and initialize a constant in C#?

  1. A. int const VALUE = 10
  2. B. const VALUE = 10
  3. C. VALUE = const 10
  4. D. const int VALUE = 10
Report Error

Which of the following is a valid constant in C#?

  1. A. const float PI = 3.14
  2. B. readonly float PI = 3.14
  3. C. float const PI = 3.14
  4. D. const PI = 3.14
Report Error

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

  1. A. To define a constant
  2. B. To make a variable accessible outside its class
  3. C. To make a variable read-only
  4. D. To indicate that a variable's value can be modified by multiple threads concurrently
Report Error

In C#, which data type is used to represent characters and symbols?

  1. A. double
  2. B. int
  3. C. char
  4. D. string
Report Error

Which of the following is NOT a valid data type in C#?

  1. A. bool
  2. B. decimal
  3. C. long double
  4. D. char
Report Error

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

  1. A. num? int
  2. B. var? num
  3. C. int? num
  4. D. nullable int num
Report Error