Chapter 2

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

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:04 AM on 9/6/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

44 Terms

1
New cards

Identifier

A name created by a programmer for an item like a variable, method, or class

2
New cards

What is camel case?

Identifier style where each word is capitalized except the first

ex. numApples

3
New cards

What is underscore seperated?

Identifier style where words are lowercase and separated by an underscore

4
New cards

What is a good practice when it comes to abbreviations in identifiers?

Avoid abbreviations in identifiers except for well-known ones

5
New cards

What is a literal?

A specific value, like 2, 3, 4, “hello”

6
New cards

What is a variable?

A named item which is used to hold a value

7
New cards

What is an operator?

Symbol that performs a built-in calculation

ex. +, -

8
New cards

What is an expression?

Combination of items, like variables, literals, operators, and parentheses, that evaluates to a value

9
New cards

What is a variable declaration?

A statement that declares a new variable, specifying the variable’s name and data type

ex. int userAge;

ex. double tickerCost;

10
New cards

How many times can you declare a variable?

Once

11
New cards

What is assignment?

To assign a variable with a value

12
New cards

What is the assignment operator?

=

13
New cards

What is initializing?

When you assign data to a variable for the first time

14
New cards

Can you initialize and declare a variable at the same time?

Yes!

ex. int avgLifespan = 70;

15
New cards

What is incrementing?

Having the same variable on both sides of an assignment. It will use the value of that variable to do the expression and then replace that variable with the result

ex. if numItems is 5

numItems = numItems + 1;

numItems will now equal 6

16
New cards

Where are expressions commonly?

On the right side of an assignment

17
New cards

What is % ?

Modulo operator to calculate the remainder

explanation- for example 51 % 2 would be 1 since the furthest 2 can get to 51 (by multiplying) is 50. so the remaining value to get to 51 would be 1.

18
New cards

What is an operand?

object to be operated

19
New cards

What is an unary operator?

takes a single operand

ex. a negative number

20
New cards

What is a binary operator?

Takes two operands

ex. y + 50

21
New cards

What is evaluated first, () or unary operators?

Parentheses ()

22
New cards

What is evaluated after unary operators?

*, /, %

23
New cards

What is a compound operator?

A shortcut way to update a variable, like wanting to add, subtract, multiply etc. to a variable that already has a value

ex. numPeople += 10

would add 10 to numPeople

24
New cards

How many bytes and bits does a byte have? What numbers can it store?

1 byte

8 bits

Store whole numbers from -128 to 127

25
New cards

How many bytes and bits does a short data type have?


2 bytes

16 bits

26
New cards

How many bytes and bits does an int have? What numbers can it store?

4 bytes

32 bits

can store + or - 2 billion

27
New cards

How many bytes and bits does a long data type have?

8 bytes

64 bits

28
New cards

What is not allowed in an integer literal?

commas are not allowed in numbers

ex. 1,350 not allowed

29
New cards

What can never be the second operand of / or %? (like on the right side of it) and why?

0 because division by 0 is mathematically undefined

30
New cards

What would happen if 0 was on the right side of / or %?

A run-time error

31
New cards

How many bits and bytes does a float data type have? What numbers can it store?

4 bytes

32 bits

Stores fractional numbers (about 6 to 7 decimal digits

32
New cards

How many bytes and bits does a double data type have? What numbers can it store?

8 bytes

64 bits

can store fractional numbers (stores 15 decimal digits)

33
New cards

What are floating-point numbers?

A real number containing a decimal point that can appear anywhere in the number

ex. 0.1 not .1

ex. 1.0 not 1.

34
New cards

What are floating-point numbers?

a literal referring to a number with a fractional part

ex. can be .14 or 0.14

35
New cards

When are integer variables typically used?

Typically used for values that are counted

ex. 42 cars

36
New cards

When are floating-point variables typically used?

For measurements

ex. 98.6 degrees

37
New cards

What does dividing a nonzero floating-point number by zero result in?

infinity or -infinity

(Note- at least one of the numbers has to be a decimal whether that be the 0 or the nonzero number)

38
New cards

What would dividing a positive floating-point number by zero result in?

infinity

ex. 3.14 / 0.0 = infinity

39
New cards

What would dividing a negative floating-point number by zero result in?

-infinity

ex. (-3.14) / 0 = =infinity

40
New cards

What would dividing 0.0 by 0.0 in a floating point division result in?

NaN (not a number)

0.0 / 0.0 = NaN

or

0.0 / 0 = NaN

41
New cards

What is allocation?

Process of determining a suitable memory location to store data like variables

42
New cards
43
New cards
44
New cards