Java Reference
In-Depth Information
9 . In Java, the logical operators are ! ( not ), && ( and ), and || ( or ).
10 . In Java, there are three selection structures.
11 . One-way selection takes the following form:
if (logical expression)
statement
If logical expression is true , then the statement executes; otherwise,
the computer executes the statement following the if statement.
12 . Two-way selection takes the following form:
4
if (logical expression)
statement1
else
statement2
If logical expression is true , then statement1 executes; otherwise,
statement2 executes.
13 . The expression in an if or if ... else structure is a logical expression.
14 . Including a semicolon before the statement in a one-way selection creates
a semantic error. In this case, the action of the if statement is empty.
15 . Including a semicolon before statement1 in a two-way selection creates a
syntax error.
16 . There is no stand-alone else statement in Java. Every else has a related if .
17 . An else is paired with the most recent if that has not been paired with
any other else .
18 . A sequence of statements enclosed between braces, { and } , is called a
compound statement or block of statements. A compound statement is
treated as a single statement.
19 . A switch structure is used to handle multiple selections.
20 . The expression in a switch statement must evaluate to an integral value.
21 . A switch statement executes according to the following rules:
a. When the value of the expression is matched against a case value,
the statements execute until either a break statement is found or the
end of the switch structure is reached.
b. If the value of the expression does not match any of the case values,
the statements following the default label execute. If the switch
structure has no default label, and if the value of the expression does
not match any of the case values, the entire switch statement is skipped.
c. A break statement causes an immediate exit from the switch structure.
22 . To compare strings, you use the method compareTo of the class String .
Search WWH ::




Custom Search