MCQ Single Best Answer Easy

QWhich type is assigned to variables with null type?

ID: #19069 Static vs Dynamic Type Checking 92 views
Question Info
#19069Q ID
EasyDifficulty
Static vs Dynamic Type CheckingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A any
  • B string
  • C None of the options
  • D boolean
Correct Answer: Option C

Explanation

In TypeScript, when a variable is assigned the value null, it is often given the type null. This is a specific type in TypeScript that represents the absence of an object value.

So, the correct answer would be:

None of the options.

The variable is given the type null when it is explicitly assigned the value null. If you don't want to specify a particular type, you would typically use the any type, but if you assign a value of null, TypeScript will consider the variable to have the type null.

Share This Question

Challenge a friend or share with your study group.