JAVA Ch 2

0.0(0)
studied byStudied by 0 people
0.0(0)
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/61

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:35 AM on 2/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

62 Terms

1
New cards

What is a constant in programming?

A value that cannot be changed while a program is running.

2
New cards

What is a variable?

A named memory location that can store a value.

3
New cards

What does a data type describe?

The type of data that can be stored, how much memory it uses, and what operations can be performed on it.

4
New cards

What is a primitive data type?

A simple, uncomplicated data type.

5
New cards

What is a reference data type?

A more complex data type that holds memory addresses.

6
New cards

What primitive data type stores a byte-length integer?

byte

7
New cards

What primitive data type stores a short integer?

short

8
New cards

What primitive data type is most commonly used for whole numbers?

int

9
New cards

What primitive data type stores long integers?

long

10
New cards

What primitive data type stores single-precision floating-point values?

float

11
New cards

What primitive data type stores double-precision floating-point values?

double

12
New cards

What primitive data type stores a single character?

char

13
New cards

What primitive data type stores true or false values?

boolean

14
New cards

What is a variable declaration?

A statement that reserves a named memory location.

15
New cards

What four components can be included in a variable declaration?

Data type, identifier (variable name), optional assignment/value, and a semicolon.

16
New cards

What is an identifier?

The name of a variable.

17
New cards

What is camel casing?

A naming style that starts with a lowercase letter and capitalizes subsequent words.

18
New cards

Give an example of camel casing.

firstName

19
New cards

What is the assignment operator?

The equals sign =.

20
New cards

How does the assignment operator work?

The value on the right is assigned to the memory location on the left.

21
New cards

What is initialization?

Assigning a value when a variable is declared.

22
New cards

What is assignment (after declaration)?

Assigning a value to a variable later in the program.

23
New cards

How many times can a variable be declared in a method?

Once

24
New cards

How many times can a variable be assigned a new value?

Any number of times.

25
New cards

What is an uninitialized variable?

A variable declared without being assigned a value.

26
New cards

What keyword is used to declare a named constant in Java?

final

27
New cards

How many times can a named constant be assigned a value?

Only once

28
New cards

What is a blank final constant?

A constant declared without an initial value.

29
New cards

When must a constant be assigned a value?

Before it is used.

30
New cards

What naming convention is used for named constants?

All uppercase letters with underscores between words.

31
New cards

What is the range of a byte?

–128 to 127

32
New cards

How many bytes does a byte use?

1 byte

33
New cards

What is the range of a short?

–32,768 to 32,767

34
New cards

How many bytes does a short use?

2 bytes

35
New cards

What is the range of an int?

–2,147,483,648 to 2,147,483,647

36
New cards

How many bytes does an int use?

4 bytes

37
New cards

What is the range of a long?

–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

38
New cards

How many bytes does a long use?

8 bytes

39
New cards

How many significant digits does a float hold?

About 6–7 digits.

40
New cards

How many significant digits does a double hold?

About 13–15 digits.

41
New cards

Which uses more memory: float or double?

Double.

42
New cards

What is the char data type used for?

Storing a single character.

43
New cards

How is a char written in Java?

Using single quotes (e.g., 'M').

44
New cards

What is a String in Java?

A built-in class used to store and manipulate character strings.

45
New cards

What does \b do?

Moves the cursor one space to the left (backspace).

46
New cards

What does \t do?

Moves the cursor to the next tab stop.

47
New cards

What does \n do?

Moves the cursor to the beginning of the next line (newline).

48
New cards

What does \r do?

Moves the cursor to the beginning of the current line.

49
New cards

What escape sequence displays a double quote?

\"

50
New cards

What escape sequence displays a single quote?

\'

51
New cards

What escape sequence displays a backslash?

\\

52
New cards

What does InputDialog do?

Prompts the user for text input.

53
New cards

What does ConfirmDialog do?

Asks a question with Yes, No, and Cancel buttons.

54
New cards

What is type conversion?

Converting one data type to another.

55
New cards

What is a unifying type?

The type all operands are converted to so they are compatible.

56
New cards

What is implicit conversion?

Automatic type conversion performed by Java.

57
New cards

Which type has the highest priority in implicit conversion?

double

58
New cards

Which type has the lowest priority in implicit conversion?

int (byte and short convert to int)

59
New cards

What happens to byte and short in expressions?

They are automatically converted to int.

60
New cards

What is type casting?

Forcing a value of one data type to be used as another.

61
New cards

Why is type casting used?

To override automatic type conversion.

62
New cards

How is a cast operator written?

By placing the desired type in parentheses, e.g. (int)