Unit 1 APCSA Prrimitives

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/105

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 11:19 PM on 9/2/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

106 Terms

1
New cards

What are Identifiers?

Names you chose for variables, methods, and classes

2
New cards

What rules must identifiers follow?

-Start with a letter

3
New cards

-Can include digits, letters, or $

4
New cards

-Can't be reserved words

5
New cards

Examples of identifiers

name, count, totalAmount, isHeads

6
New cards

What are reserved words?

Built in java words used for its language structure.

7
New cards

Examples of reserved words

class, public, static, int, if, return, new

8
New cards

What is a compile time error?

A error that prevents the program from running successfully.

9
New cards

What is a runtime error?

An error that occurs while the code is running, so the code crashes.

10
New cards

What is a logical error code?

Code works, answer is wrong.

11
New cards

What does println do?

Prints info and moves cursor to next line.

12
New cards

What does print do?

Prints info and keeps cursor on that line

13
New cards

What are parameters?

variables listed in a methods definition that receive information when the method is called

14
New cards
15
New cards

Example:

16
New cards

public static void greet(String name) {

17
New cards

System.out.println("Hello " + name); }

18
New cards
19
New cards

String name = parameter

20
New cards

How many arguments can print and println take?

One argument per method call

21
New cards

What does braces look like?

{ }

22
New cards

What do brackets look like?

[ ]

23
New cards

What do parenthesis look like?

( )

24
New cards

How to get newline?

\n

25
New cards

How to get double quote?

\"

26
New cards

How to get backslash?

\

27
New cards

How to tab?

\t

28
New cards

What are the primitive data types?

int (integers)

29
New cards

double (decimals)

30
New cards

boolean (true or false)

31
New cards

What is a variable?

A named storage location that holds one value at a time. Its value can be changed unless it is declared final.

32
New cards

the double variable is for…

decimals

33
New cards

the int variable is for…

integers

34
New cards

the boolean variable is for…

true or false

35
New cards

In double height; what is a double?

The data type

36
New cards

In double height; what is the height?

variable name (identifier)

37
New cards

What is int sides = 10

A declaration and initialization. It declares sides as an int and gives it its initial value of 10.

38
New cards

What is sides = 10?

An assignment statement. It assigns/stores the value 10 in the variable sides.

39
New cards

How many values can a variable store one it is declared?

1

40
New cards

int legs = 4

41
New cards

How to print "My dog has 4 legs"

System.out.println("My dog has " + legs + " legs");

42
New cards

What is a constant?

A variable whos value cannot be changed after it is initialized. It is declared using the final.

43
New cards
44
New cards

Example

45
New cards

final int LEGS = 4;

46
New cards

Example of how to make a constant?

final int legs = 4

47
New cards

Multiplication symbol

*

48
New cards

Division symbol

/

49
New cards

Modular division symbol

%

50
New cards

What happens when you perform arithmetic using two int values?

The result is an int. For division, the decimal portion is discarded.

51
New cards

10/4 =

2

52
New cards

2*4 =

8

53
New cards

1/4 =

0

54
New cards

What happens when an arithmetic operation includes a double?

The result is a double.

55
New cards

2*4.0 =

8.0

56
New cards

10/4.0 =

2.5

57
New cards

What does System.out.println(1/3*90); print.

0

58
New cards

What does the Modulus operator % do?

It gives the remainder after division.

59
New cards

40 % 11 =

7

60
New cards

17 % 2

1

61
New cards

4 % 5

4

62
New cards

What is widening?

Converting a value from a smaller numeric type to a larger numeric type, such as int > double.

63
New cards

What is narrowing?

Converting a value from a larger numeric type to a smaller numeric type, such as double > int.

64
New cards

What is the one way to convert and int to a double?

Assign the int to a double variable.

65
New cards
66
New cards

int num1 = 1

67
New cards

double num2 = num1

68
New cards

Can you automatically assign a double to an int?

No

69
New cards

How can arithmetic with an int produce a double.

Include a double in the arithmetic operation

70
New cards
71
New cards

int num = 5

72
New cards

System.out.println(num/4.0); yields 1.25

73
New cards

What is casting?

Explicitly converting a value to another data type by putting the desired type in parentheses before the value/expression.

74
New cards

Does casting a double to an int round the number?

No, it removes/discards the decimal portion.

75
New cards

What is the result of this code

76
New cards

double a + 4.4, b = 7.5;

77
New cards

int c = (int)(a + b);

C = 11

78
New cards

How to assign "11d" to an int?

11*d

79
New cards

What is an argument?

The actual value or expression passed to a method when it is called. Arguments go inside the parentheses.

80
New cards
81
New cards

System.out.println("Hello");

82
New cards

Hello is the argument

83
New cards

What is double height?

A variable declaration. It tells Java to create a variable named height that can store a double.

84
New cards

What does System.out.println(1/3*90.0); print?

0.0

85
New cards

What does = mean in Java?

Assignment. It stores the value on the right on the right in the variable on the left.

86
New cards

What does == mean in java?

Equality comparison. It checks whether two values are equal and produces a Boolean.

87
New cards

What is a string?

A sequence of characters/text enclosed in double quotation marks.

88
New cards
89
New cards

Example: "Hello"

90
New cards

What does + do when used with strings?

It concatenates, or joins, Strings and other values together

91
New cards
92
New cards

Example "Age: " + age

93
New cards

What is initialization?

Giving a variable its first value when it is declared?

94
New cards
95
New cards

Int age = 16;

96
New cards

What is an escape sequence?

A combination with \ that represents a special character or action inside a String,

97
New cards
98
New cards

Examples: \n \t \

99
New cards

How can % be used to determine whether an integer is even?

Check whether number % 2 is even.

100
New cards

How can % be used to determine whether an integer is odd?

Check whether number % 2 is odd.