Java Reference
In-Depth Information
4.24
Show the output of the following statements.
(a)
System.out.printf(
"amount is %f %e\n"
,
32.32
,
32.32
);
(b)
System.out.printf(
"amount is %5.2%% %5.4e\n"
,
32.327
,
32.32
);
(c)
System.out.printf(
"%6b\n"
,
(
1
>
2
));
(d)
System.out.printf(
"%6s\n"
,
"Java"
);
(e)
System.out.printf(
"%-6b%s\n"
,(
1
>
2
),
"Java"
);
(f)
System.out.printf(
"%6b%-8s\n"
,(
1
>
2
),
"Java"
);
K
EY
T
ERMS
char
type 125
encoding 125
escape character
instance method 130
static method 130
supplementary Unicode
127
125
escape sequence
126
Unicode 125
whitespace character
format specifier
146
133
C
HAPTER
S
UMMARY
1.
Java provides the mathematical methods
sin
,
cos
,
tan
,
asin
,
acos
,
atan
,
toRadians
,
toDegree
,
exp
,
log
,
log10
,
pow
,
sqrt
,
cell
,
floor
,
rint
,
round
,
min
,
max
,
abs
, and
random
in the
Math
class for performing mathematical functions.
2.
The character type
char
represents a single character.
3.
An escape sequence consists of a backslash (
\
) followed by a character or a combina-
tion of digits.
4.
The character
\
is called the escape character.
5.
The characters
' '
,
\t
,
\f
,
\r
, and
\n
are known as the whitespace characters.
6.
Characters can be compared based on their Unicode using the relational operators.
7.
The
Character
class contains the methods
isDigit
,
isLetter
,
isLetterOrDigit
,
isLowerCase
,
isUpperCase
for testing whether a character is a digit, letter, lower-
case, and uppercase. It also contains the
toLowerCase
and
toUpperCase
methods for
returning a lowercase or uppercase letter.
8.
A
string
is a sequence of characters. A string value is enclosed in matching double
quotes (
"
). A character value is enclosed in matching single quotes (
'
).
9.
Strings are objects in Java. A method that can only be invoked from a specific object is
called an
instance method
. A non-instance method is called a static method, which can
be invoked without using an object.
Search WWH ::
Custom Search