Chapter 4: Fundamental Data Types Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How many primitive types are in java?

A

8

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

How many integer types are there?

A

4

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

How many floating-point types in java?

A

2

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

What is Integer.MAX_Value?

A

2.14 billion

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

What is Integer.MIN_VALUE

A

-2.14 billion

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

What is a number literal?

A

any number in a java program

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

What happens when a numeric computation overflows?

A

the result falls outside the range for the number type

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

T/F There is a warning when a numeric computation overflows?

A

False

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

What is the simplest remedy for numeric computation overflows?

A

Use the long type

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

T/F: It is legal to assign an integer type to a floating-point variable

A

true

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

When does a rounding error occur?

A

when an exact representation of a floating-point number is not possible

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

T/F: it is legal to assign a double value to an int value?

A

false - it is an assignment error

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

What are numerical constants?

A

values that do not change and have special significance for a computation

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

What happens when you tag a variable final?

A

You can never change after it has been set

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

What do many programmers name constants?

A

All upper case, separating words with underscores

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

How are constants declared?

A

public

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

What is an expression

A

The combination of variables, literals, and/or method calls

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

What does integers and floating-point values in an arithmetic expression yield?

A

a floating-point value

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

What does the ++ operator do?

A

adds 1 to a variable

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

What does the – operator do?

A

subtracts 1 from a variable

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

If both arguments are integers, and the mathematical result is a floating-point number, what happens to the remainder?

A

It is discarded

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

What does the modulus operator compute?

A

the remainder of an integer division

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

What is the modulus operator?

A

%

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

How do you take the square root of a number?

A

Math.sqrt(x)

25
Q

How do you take a number to the power?

A

Math.pow(x, y)

26
Q

How do you take the sin of a number?

A

Math.sin(x)

27
Q

How do you take the cosine of a number?

A

Math.cos(x)

28
Q

How do you take the tangent of a number?

A

Math.tan(x)

29
Q

How do you find the closest integer to x?

A

Math.round(x)

30
Q

How do you find the smallest integer greater than x

A

Math.ceil(x)

31
Q

How do you convert degrees to radians?

A

Math.toRadians(x)

32
Q

How do you take the absolute value of a number

A

Math.abs(x)

33
Q

How do you find the larger of two numbers

A

Math.max(x, y)

34
Q

How do you find the smaller of two numbers

A

Math.min(x, y)

35
Q

How do you find e to the power of x

A

Math.exp(x)

36
Q

How do you find the log of x, given that x is greater than 0?

A

Math.log(x)

37
Q

How do you find the decimal log of x?

A

Math.log10(x)

38
Q

How do you find the largest int that is less than x

A

Math.floor(x)

39
Q

How do you convert radians to degrees?

A

Math.toDegrees(x)

40
Q

How do you convert a value to a different type?

A

use a cast(typeName)

41
Q

What does text consist of?

A

characters

42
Q

What are characters?

A

letters, numbers, punctuations, spaces, and so on

43
Q

What is a string?

A

a sequence of characters

44
Q

What does a string literal do?

A

denote a particular string

45
Q

What does it mean to concatenate two strings?

A

to combine two strings into one large string

46
Q

What operator do you use to concatenate strings?

A

+

47
Q

Can you concatenate a int?

A

Yes - as long as one of the arguments of the + operator is a string

48
Q

How do you include a quotation mark in a literal string

A

A backslash ()
e.x.:
“He said "Hello"”

49
Q

What is this sequence called: "

A

escape sequence

50
Q

How do you use a backslash in a string

A

Use this escape sequence: \

51
Q

What does \n denote?

A

A newline character

52
Q

What are strings sequences of?

A

unicode characters

53
Q

What type are characters?

A

char

54
Q

How are characters formatted?

A

enclosed by singular quotation marks
e.x.
‘a’

55
Q

What method returns the char value of a string

A

charAt

56
Q

What position is the first character of a string at?

A

0

57
Q

What does the substring method do?

A

extracts a part of a string

58
Q

What is the syntax of the substring method?

A

str.substring(start, pastEnd)