# 1.3 Expressions and Output

#### Topic 1.3 — Expressions and Output

**Suggested Skills:** 2.A, 3.A, 3.D

**LO 1.3.A** — Develop code to generate output and determine the result that would be displayed.

* **1.3.A.1** — `System.out.print` and `System.out.println` display information on the computer display. `System.out.println` moves the cursor to a new line after the information has been displayed, while `System.out.print` does not.

**LO 1.3.B** — Develop code to utilize string literals and determine the result of using string literals.

* **1.3.B.1** — A **literal** is the code representation of a fixed value.
* **1.3.B.2** — A **string literal** is a sequence of characters enclosed in double quotes.
* **1.3.B.3** — **Escape sequences** are special sequences of characters that can be included in a string. They start with a `\` and have a special meaning in Java. Escape sequences used in this course include double quote `\"`, backslash `\\`, and newline `\n`.

**LO 1.3.C** — Develop code for arithmetic expressions and determine the result of these expressions.

* **1.3.C.1** — Arithmetic expressions, which consist of numeric values, variables, and operators, include expressions of type `int` and `double`.
* **1.3.C.2** — The arithmetic operators consist of addition `+`, subtraction `-`, multiplication `*`, division `/`, and remainder `%`. An arithmetic operation that uses two `int` values will evaluate to an `int` value. An arithmetic operation that uses at least one `double` value will evaluate to a `double` value.
  * ❌ **EXCLUSION** — Expressions that result in special `double` values (e.g., infinities and NaN) are outside scope.
* **1.3.C.3** — When dividing numeric values that are both `int` values, the result is only the integer portion of the quotient. When dividing numeric values that use at least one `double` value, the result is the quotient.
* **1.3.C.4** — The remainder operator `%` is used to compute the remainder when one number `a` is divided by another number `b`.
  * ❌ **EXCLUSION** — The use of values less than 0 for `a` and the use of values less than or equal to 0 for `b` is outside scope.
* **1.3.C.5** — Operators can be used to construct compound expressions. At compile time, numeric values are associated with operators according to **operator precedence** to determine how they are grouped. Parentheses can be used to modify operator precedence. Multiplication, division, and remainder have precedence over addition and subtraction. Operators with the same precedence are evaluated from left to right.
* **1.3.C.6** — An attempt to divide an integer by the integer zero will result in an `ArithmeticException`.
  * ❌ **EXCLUSION** — The use of dividing by zero when one numeric value is a `double` is outside scope.
