Java Language Lexicon: Whitespace, Identifiers, Keywords & Comments - Quiz

Total: 2 questions

1. 

Which characters can a Java identifier start with?

An identifier must start with a letter, a currency character such as $, or a connecting character such as the underscore _. It cannot start with a digit: 6j and 5g do not compile, while _n, $p and name do. Since Java 9 a single underscore _ on its own is a keyword and cannot be used as an identifier.

2. 

Which characters can a Java identifier contain after the first character?

After the first character an identifier may contain any combination of letters, digits, currency characters ($) and connecting characters (_). Spaces and other symbols such as #, ., : or - are not allowed, so my-temp and j# are illegal. There is no length limit, identifiers are case-sensitive (count and Count are different names), and a keyword such as class cannot be an identifier.

Page 1 of 1