Const and goto arent actually used java
Declaring and Initializing Variables 27
of type double. Although that’s true, it still isn’t allowed. If you want to declare multiple variables in the same statement, they must share the same type declaration and not repeat it. double d1, d2; would have been legal.
i4;// DOES NOT COMPILE
Looking at the last line on its own, you can easily see that the declaration is invalid.
■ The name must begin with a letter or the symbol $ or _.
■ Subsequent characters may also be numbers.
28 |
|
||||
---|---|---|---|---|---|
abstract | assert |
|
|||
catch | |||||
continue | default |
|
|
||
extends |
|
||||
|
for | ||||
instanceof |
|
|
|||
new |
|
||||
|
|||||
strictfp | super |
|
|
||
throws | transient | ||||
|
volatile |
|
Although you can do crazy things with identifi er names, you shouldn’t. Java has con-ventions so that code is readable and consistent. This consistency includes CamelCase. In CamelCase, each word begins with an uppercase letter. This makes multiple-word variable names easier to read. Which would you rather read: Thisismyclass name or ThisIsMyClass name? The exam will mostly use common conventions for identifi ers, but not always. When you see a nonstandard identifi er, be sure to check if it is legal. If not, you get to mark the answer “does not compile” and skip analyzing everything else in the question.