Big Java: 2 Flashcards

1
Q

how to make it so that the value of a variable is never changeable?

A

in the declaration, precede the type with the word “final”

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

the three different types of delimiters (allow comments)

A
/** this program does etc */
/* this part does */
//this delimeter only end till end of this line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

if we want an exact quotient, make sure that when dividing, at least one of the numbers is

A

a double

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

when two integers are divided…

A

the result is rounded down (the remainder is discarded)

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

how to compute x^n

A

Math.pow(x, n)

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

how to round to the closest integer to x

A

Math.round(x)

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

how to take the absolute value of x

A

Math.abs(x)

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

how to take the larger or smaller value from x and y

A

Math.max(x, y)

Math.min(x, y)

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

how to display a variable with two places after the decimal point

A

System.out.printf( “%.2f”, variablenamehere );

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