Lec 3: Numbers and Math Flashcards

1
Q

What is a literal

A

A constant value that appears directly in a program

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

What is the storage size of a byte?

A

8 bit signed

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

What is the storage size of a short?

A

16 bit signed

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

What is the storage size of an int?

A

32 bit signed

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

What is the storage size of a long

A

64 bit signed

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

What is the storage size of a float

A

32 bit IEEE 754

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

What is the storage size of a double

A

64 bit IEEE 754

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

True or false: Int variables store numbers accurately?

A

True

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

True or false: float numbers store numbers accurately?

A

False

System.out.println(1.0-0.9); gives 0.09999999998 and not 0.1

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

What data type is truncated when divided with itself?

A

Int

5/2 yields 2

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

What is truncated

A

not to be mistaken with rounding
returns the int down

5/2 yields 2

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

math operative conversion rules

A

If one operand is double, the other is converted to double
otherwise if one is float, the other is converted into float
otherwise if one is long, the other is converted to long

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

True or False: When casting a double to int, it truncates

A

True

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

Operator precedence

A
  • (), var++, var–
  • ++var, –var, +, - (unary plus and minus), ! (not)
  • (type) casting
  • *, /, % (multiplication, division, and remainder)
  • +, - (binary addition and subtraction)
  • <, <=, >, >= (relational operators)
  • ==, != (equality)
  • ^ (exclusive or)
  • && (and)
  • || (or)
  • =, +=, -=,*=, /=, %= (assignment operators)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how to import java scanner to listen to input

A

import java.util.Scanner

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

What does Math.ceil(3.5) return?

A

4.0

17
Q

What does Math.floor(3.5) return?

A

3.0

18
Q

Does Math.sin() take in degrees or radians?

A

radians

19
Q

Does Math.round(3.6) return a double?

A

No, it returns an int

20
Q

Does Math.rint(3.6) return a double?

A

Yes, it returns 4.0

21
Q

What does Math.ceil(3.6) return?

A

4.0