1.3 Expressions and Assignment Statements

Part I

Enduring Understanding

The way variables and operators are sequenced and combined in an expression determines the computed result.

Learning Objective

Evaluate arithmetic expressions in a program code.

Essential Knowledge

  • A literal is the source code representation of a fixed value.

  • Arithmetic expressions include expressions of type int and double.

  • The arithmetic operators consist of +, −, *, /, and %.

  • An arithmetic operation that uses two int values will evaluate to an int value.

  • An arithmetic operation that uses a double value will evaluate to a double value.

  • Operators can be used to construct compound expressions.

  • During evaluation, operands are associated with operators according to operator precedence to determine how they are grouped.

  • An attempt to divide an integer by zero will result in an ArithmeticException to occur.

Introduction

Learning Objective

Evaluate what is stored in a variable as a result of an expression with an assignment statement.

Essential Knowledge

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.

During execution, expressions are evaluated to produce a single value.

The value of an expression has a type based on the evaluation of the expression.

Last updated

Was this helpful?