Java Data Types Flashcards

1
Q

What is a variable?

A

A storage location in RAM

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

What 2 things must a variable have?

A

A name and a data type

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

What are 3 other words for variable “name”?

A

1) Identifier
2) Reference
3) Handle

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

What are we doing when we declare a variable?

A

Binding the name to a specific memory address

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

What can you NOT start a variable name with?

A

Number

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

What three things can you start a variable name with?

A

1) Letter
2) Underscore
3) $

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

What words can you not use for naming variables?

A

Java Reserved Words

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

What kind of notation is used for naming variables?

A

camelBack

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

What notation is used for naming classes?

A

TitleCase

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

Why do we specify data type when declaring variables?

A

Tells OS how many bytes of memory to allocate and helps interpret data.

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

How many characters are shared between ASCII and Unicode?

A

256

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

Primitive data types are the only things in Java that are not _______. Why?

A

Objects, because they have no methods.

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

How many primitive data types are there?

A

8

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

How many numeric primitive data types are there?

A

6

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

How many bits in a byte data type?

A

8 (1 byte)

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

How many bits in a short?

A

16 (2 bytes)

17
Q

How many bits in an int?

A

32 (4 bytes)

18
Q

How many bits in a long?

A

64 (8 bytes)

19
Q

How many floating primitive types are there?

A

Two, float and double.

20
Q

How many bits in a float?

A

32 (4 bytes)

21
Q

How many bits in a double?

A

64 (8 bytes)

22
Q

What are the two non-numeric data types?

A

char and boolean

23
Q

How many bits in the char data type?

A

16 (2 bytes)

24
Q

What are the two default numeric primitive data types?

A

int and double

25
Q

How are floating numbers stored in Java?

A

A mantissa and an exponent

26
Q

What data type is a String?

A

Object

27
Q

What is the naming convention for constants?

A

UPPER_CASE_LETTERS

28
Q

What keyword is used when declaring a constant?

A

final

29
Q

What is a data literal?

A

The actual data value that appears in a program.

ex. ‘A’, or “Hello World”

30
Q

How do you get Java to interpret a very long number properly?

A

Add an ‘L’ to the end of it.

31
Q

When dividing integers by integers, Java ______ the answer.

A

Truncates

32
Q

Which operator returns the remainder from division?

A

Modulus (%)

33
Q

What are the unary operators?

A

(+ and -), denoting positive and negative

34
Q

What is the increment operator?

A

++

35
Q

When do you need to explicitly use type casting?

A

When assigning a larger data type to a variable with less capacity.
ex. assigning type int data to a variable of short.

36
Q

What is type casting?

A

Converts a value of one data type into a value of another data type.

37
Q

What is a common error of type casting?

A

Overflow