APCSA Unit 1 - Primitive Types

0.0(0)
studied byStudied by 10 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/53

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

54 Terms

1
New cards

How do you start a java code?

public static void main (String [] args)

2
New cards

What is a statement in java? Give an example.

A complete argument in java. Example: System.out.print(“literal”);

3
New cards

What is a class in Java? Give an example.

A template that associates and creates objects that share common properties and methods. Your public class must match the name of the file with a .java extention. Example: public class MyClass

4
New cards

What is a keyword in Java? Give an example.

A word reserved by java to run code. Example: if, public, and class

5
New cards

How do you make comments in java?

With two slashes (//) or with a slash and an asterisk and a backslash and an asterisk (/**/)

6
New cards

What is a variable?

A name associated with a memory location in the computer where you can create a value to change or vary.

7
New cards

Give an example of how to combine literals and variables and have the computer print both.

System.out.print (“base: “ + base);

8
New cards

Give an example on how to declare a variable only.

int a

9
New cards

Give an example on how to set an initial value for a variable only.

a = 4

10
New cards

Give an example of how to set a variable and give it a variable.

int a = 4

11
New cards

What is an int variable?

Interger (math variable)

12
New cards

What is a double variable?

Decimal (math variable)

13
New cards

What is a String variable?

A variable that includes quotes and string text

14
New cards

What is a boolean variable?

A variable that can only be True or False

15
New cards

How do you find the answer of a decimal problem in decimals in java?

Use the primitive variable double and include decimal points in any number included.

16
New cards

List all the math operators.

+,-,*,/,and %

17
New cards

What are compound operators? List them.

Operators that use two math symbols. -- subtracts one, ++ adds one, a+=2 would set a to a + 2.

18
New cards

What does / do in java?

Divides two numbers and gives an integer answer (no remainder)

19
New cards

What does % do in java?

Gives only the remainder of a division problem.

20
New cards

What are the types of variables?

Primitive and object or reference variables

21
New cards

What are the primitive variable types in java?

int, double, string, boolean

22
New cards

What is the string variable used for?

Secquences of charectes

23
New cards

How many bits does a boolean variable use?

1

24
New cards

What is the string concatenation operator?

+

25
New cards

What does final do in java?

stops a variable from being changed

26
New cards

What is camel case?

When you uppercase the first letter

27
New cards

What is an assign statement?

A statement that changes the value

28
New cards

What is this operator called %?

Modulo

29
New cards

What is 11 % 10 saying?

What is the remainder of how many times 10 goes into 11?

30
New cards

Does the division operator drop the decimal after dividing?

Yes, no rounding

31
New cards

Variable

A name associated with a memory location in the computer.

32
New cards

boolean

used to declare a variable that can only have the value true or false.

33
New cards

double

used to declare a variable that is a decimal number like 3.25.

34
New cards

int

used to declare a variable of type integer (a whole number like -3 or 235).

35
New cards

static

means that the field or method exists in the object that defines the class.

36
New cards

compiler

Software that translates the Java source code into the Java class file that can be run.

37
New cards

compiler or syntax error

An error or bug that is found by the compiler like a missing semicolon

38
New cards

Main Method

Where execution starts in a Java program.

39
New cards

Boolean

An expression that is either true or false.

40
New cards

Camel Case

One way to create a variable name by appending several words together and uppercasing the first letter of each word after the first word (myScore).

41
New cards

Casting a Variable

Changing the type of a variable using (type) name.

42
New cards

System.out.println()

Java method that lets us print out a line of output followed by a newline to the user

43
New cards

Declare a Variable

Specifying the type and name for a variable. This sets aside memory for a variable of that type and associates the name with that memory location.

44
New cards

Initializing a Variable

The first time you set the value of a variable.

45
New cards

String literal

Text enclosed by double quotes.

46
New cards

modulo

The % operator which returns the remainder from one number divide by another.

47
New cards

Operator

Common mathematical symbols such as + for addition and * for multiplication.

48
New cards

Shortcut or compound assignment operators

Operators like x++ or x+= 1 which mean x = x + 1

49
New cards

assignment statements

initialize or change the value stored in a variable using the assignment operator =.

50
New cards

data type

determines the size of memory reserved for a variable, for example int, double, boolean, String.

51
New cards

ArithmeticException

If you divide by zero, you will get this error.

52
New cards

operator precedence

Some operators are done before others, for example *, /, % have precedence over + and -, unless parentheses are used.

53
New cards

arithmetic expression

a sequence of operands and operators that describe a calculation to be performed, for example 3*(2 + x)

54
New cards

increment operator

The operator (++) that increases the value of a numerical variable by one.