Chapter 4: Fundamental Data Types 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
How do you take a number to the power?
Math.pow(x, y)
26
How do you take the sin of a number?
Math.sin(x)
27
How do you take the cosine of a number?
Math.cos(x)
28
How do you take the tangent of a number?
Math.tan(x)
29
How do you find the closest integer to x?
Math.round(x)
30
How do you find the smallest integer greater than x
Math.ceil(x)
31
How do you convert degrees to radians?
Math.toRadians(x)
32
How do you take the absolute value of a number
Math.abs(x)
33
How do you find the larger of two numbers
Math.max(x, y)
34
How do you find the smaller of two numbers
Math.min(x, y)
35
How do you find e to the power of x
Math.exp(x)
36
How do you find the log of x, given that x is greater than 0?
Math.log(x)
37
How do you find the decimal log of x?
Math.log10(x)
38
How do you find the largest int that is less than x
Math.floor(x)
39
How do you convert radians to degrees?
Math.toDegrees(x)
40
How do you convert a value to a different type?
use a cast(typeName)
41
What does text consist of?
characters
42
What are characters?
letters, numbers, punctuations, spaces, and so on
43
What is a string?
a sequence of characters
44
What does a string literal do?
denote a particular string
45
What does it mean to concatenate two strings?
to combine two strings into one large string
46
What operator do you use to concatenate strings?
+
47
Can you concatenate a int?
Yes - as long as one of the arguments of the + operator is a string
48
How do you include a quotation mark in a literal string
A backslash (\) e.x.: "He said \"Hello\""
49
What is this sequence called: \"
escape sequence
50
How do you use a backslash in a string
Use this escape sequence: \\
51
What does \n denote?
A newline character
52
What are strings sequences of?
unicode characters
53
What type are characters?
char
54
How are characters formatted?
enclosed by singular quotation marks e.x. 'a'
55
What method returns the char value of a string
charAt
56
What position is the first character of a string at?
0
57
What does the substring method do?
extracts a part of a string
58
What is the syntax of the substring method?
str.substring(start, pastEnd)