1.4 Assignment Statements and Input

Suggested Skills: 2.A, 4.A

LO 1.4.A — Develop code for assignment statements with expressions and determine the value that is stored in the variable as a result of these statements.

  • 1.4.A.1 — Every variable must be assigned a value before it can be used in an expression. That value must be from a compatible data type. A variable is initialized the first time it is assigned a value. Reference types can be assigned a new object or null if there is no object. The literal null is a special value used to indicate that a reference is not associated with any object.

  • 1.4.A.2 — The assignment operator = allows a program to initialize or change the value stored in a variable. The value of the expression on the right is stored in the variable on the left.

    • EXCLUSION — The use of assignment operators inside expressions (e.g., a = b = 4; or a[i += 5]) is outside scope.

  • 1.4.A.3 — During execution, an expression is evaluated to produce a single value. The value of an expression has a type based on the evaluation of the expression.

LO 1.4.B — Develop code to read input.

  • 1.4.B.1 — Input can come in a variety of forms, such as tactile, audio, visual, or text. The Scanner class is one way to obtain text input from the keyboard.

    • EXCLUSION — Any specific form of input from the user is outside scope.

Last updated

Was this helpful?