Identify the invalid identifier

  1. my-function

  2. size

  3. –some word

  4. This&that


Correct Option: D

AI Explanation

To answer this question, you need to understand the rules for valid identifiers in programming languages.

An identifier is a name given to a variable, function, or other programming entity. It is typically used to refer to that entity within the program.

Let's go through each option to understand why it is correct or incorrect:

Option A) my-function - This option is a valid identifier because it consists of letters, numbers, or underscores, and does not start with a number.

Option B) size - This option is a valid identifier because it consists of letters, numbers, or underscores, and does not start with a number.

Option C) –some word - This option is an invalid identifier because it contains a hyphen (-), which is not allowed in many programming languages. Hyphens are typically used for subtraction or negation, so they are not allowed in identifiers.

Option D) This&that - This option is an invalid identifier because it contains the ampersand (&) symbol, which is not allowed in many programming languages. Ampersands are typically used for logical operations or bitwise operations, so they are not allowed in identifiers.

The correct answer is D. This option is invalid because it contains the ampersand (&) symbol, which is not allowed in many programming languages.

Find more quizzes: