CompTIA A+ Core 2 Exam: Storing Data in Scripts or Code

Which Variable Type to Use for Storing 'Chicago'

Question

Which of the following variable types should be used to store the data 'Chicago' within a script or code?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

The correct answer is B. String.

In programming, variables are used to store data that can be manipulated by the program. A variable's data type determines the type of data that can be stored in it.

In this case, the data "Chicago" is a sequence of characters, which should be stored in a variable of the string data type. String variables can hold any sequence of characters, including letters, numbers, and symbols, and are commonly used to represent text data.

The other data types listed in the answers have different purposes and are not appropriate for storing the data "Chicago".

  • Integer variables are used to store whole numbers, and cannot hold text data like "Chicago".
  • Boolean variables can only hold true/false values, which are not appropriate for storing the text data "Chicago".
  • Float variables are used to store decimal numbers, which are not applicable to the text data "Chicago".

Therefore, the correct answer is B. String.