Chapter 4: Mathematical Functions, Characters, and Strings Flashcards

1
Q

What are the trigonometric methods?

A

sin(radians), cos(radians), tan(radians): RETURNS AN ANGLE IN RADIANS.

toRadians(degree), toDegrees(radians): CHANGES DEGREES TO RADIANS OR RADIANS TO DEGREE.

asin(a), acos(a), and atan(a): RETURNS THE ANGLE IN RADIANS FOR INVERSE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the exponent methods?

A

exp(x): RETURNS E TO THE POWER OF X

log(x): RETURNS THE NATURAL LOGARITHM OF X

log10(x): RETURNS THE LOG BASE OF 10 OF X

pow(a,b): RETURNS A TO THE POWER OF B

sqrt(x): RETURNS THE SQUARE ROOT OF X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the rounding methods?

A

ceil(x): x IS ROUNDED UP TO NEAREST INTEGER

floor(x): x IS ROUNDED DOWN TO NEAREST INTEGER

rint(x): x IS ROUNDED TO ITS NEAREST INTEGER. IF EQUALLY CLOSE THE EVEN NUMBER IS RETURNED AS A DOUBLE

round(x): RETURNS INT IF VALUE IS FLOAT, RETURNS LONG IF VALUE IS DOUBLE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the min method?

A

Math.min(a, b) returns the minimum of the two numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the max method?

A

Math.max(a, b) returns the maximum of the two numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the absolute method?

A

Math.abs(x) returns the absolute value of a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the random method?

A

Math.random() returns a random number greater than or equal to 0 and less than 1.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to differentiate a string and a char when initializing?

A

A string is inside double quotations (“ “) and char is inside single quotations (‘ ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Name the escape sequences for special characters.

A
\b - Backspace
\t - Tab
\n - Linefeed
\f - Formfeed
\r - Carriage Return
\\ - Backslash
\" - Double Quote Mark
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What method returns the length of a string?

A

length();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you concatenate string?

A

You can use the + operator and the += operator to link strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What’s the difference between the next() and nextLine() methods?

A

next() reads the next string that ends with a white space character, nextLine() reads the next string that ends with the Enter key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How should you check to see if two strings are identical?

A

You should use the equals method instead of the == operator.
EG:
if (string1.equals(string2))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you specify how many decimal places you want output?

A

You can use the printf method. “Interest is %4.2f”

The 4 is the field width, the 2 is the precision, and the f is the conversion code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are some frequently used format specifiers?

A
%b - A boolean value
%c - A character 
%d - A decimal integer
%f - A floating-point number
%e - Number in scientific notation
%s - A string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly