Introduction to Variables Flashcards

1
Q

What are the 8 Primitive data types?

A

byte, short, integer, long, float, char, double, boolean.

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

what data type has values of true or false?

A

boolean

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

what data type has values of -128 to 127

A

byte

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

what data type has values of -32,768 to 32,767

A

short

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

what data type has values of -2 million to 2 million

A

integer

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

what data type has values of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,808

A

long

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

what data type has values of a max of 6 to 7 decimal digits

A

float

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

what data type has values of @, *, +, a, 1, c

A

char

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

what data type has values of a max of 15 decimal digits

A

double

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

What is the difference between a primitive data type vs. reference storage?

A

primitive variables store the actual values.
reference variables stores the addresses of the objects they refer to.

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

what is the 1 reference data type?

A

String.

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

what is the syntax to declare a variable and not assign a value?

A

dataType variableName;

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

when you want to set a variable after its been declared, what do you do?

A

variable name = value;

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

In variable naming the name cannot include white space, cannot start with a number, cannot be a java reserved word, needs to be unique, and is case sensitive. What should variable naming also do?

A

variable naming should describe the data it holds.

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

how do you declare multiple variables in one statement? (asking for the syntax you would use)

A

dataType variableName1, variableame2
ex. String firstName, lastName

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

what is an instance variable?

A

a instance variable is a variable declared within a class, but outside any methods, constructors, or code blocks.

17
Q

What is this line of code String Title = “Beautiful Day” an example of in this code block?

public class Song {
String Title = “Beautiful Day”;
String Artist;
public void SetArtist (String Singer) {
Artist = Singer;
}
}

A

an instance variable

18
Q

How would you print data in java?

A

System.out.println();

19
Q

what is the syntax to declare an array?

A

dataType[] variableName = {“thing1”, “thing2”, “thing3”};