Han

Han Ferik

Home | Projects | AP CSA

AP CSA Unit 1: Primitive Types

1.1:

1.1(1):

- You must spell things correctly, or at least consistently.

- Java is a class-based language where everything is defined within a class, and the class name must match the file name.

- The Main Method controls the program's actions.

- System.out generates output to the console.

- System.out.print() displays text and keeps the cursor on the same line.

- System.out.println() displays text and moves the cursor to the next line.

1.1(2):

- A string literal is a sequence of characters enclosed in double quotes (e.g., "This is a string literal.").

1.1(3):

- Syntax errors, such as missing semicolons, prevent the program from compiling.

- Logic errors occur when the program runs but produces incorrect results due to faulty reasoning.

1.2:

1.2(1):

- A type defines a set of values and operations on them.

- Data types can be primitive (e.g., int, boolean, double) or reference types.

1.2(2):

- Variables consist of letters, digits, or underscores and are case-sensitive.

- Variable names cannot start with a digit or use spaces or special characters.

- Use camel case for variable names (e.g., myVariable).

1.3:

1.3(1):

- A literal represents a fixed value (e.g., numbers, characters).

- Arithmetic operations include +, -, *, /, and % (modulus).

1.3(2):

- Operator precedence determines the order of arithmetic operations. Parentheses take precedence over *, /, %, followed by + and -.

1.4:

1.4(1):

- Compound assignment operators include +=, -=, *=, /=, %=.

1.4(2):

- Increment (++) and decrement (--) operators add or subtract 1 from a variable.

1.5:

1.5(1):

- Division with integers truncates the decimal part. Use double to get a floating-point result.

1.5(2):

- Integer.MAX_VALUE and Integer.MIN_VALUE represent the largest and smallest possible integer values.

Find me on the interwebs!

Github LinkedIn Instagram Facebook