KnowledgeBoat Logo

Computer Applications

Identify the invalid identifier from the following:

Values & Data Types Java

3 Likes

Answer

1value

Reason — In Java, an identifier (e.g., variable, method, or class name) must follow these rules:

  1. It cannot start with a digit (e.g., 1value is invalid because it starts with 1).
  2. It can start with a letter, an underscore (_), or a dollar sign.
  3. It can contain letters, digits, underscores (_), and dollar signs after the first character.

As 1value starts with a digit, hence it is an invalid identifier.

Answered By

1 Like


Related Questions