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.printandSystem.out.printlndisplay information on the computer display.System.out.printlnmoves the cursor to a new line after the information has been displayed, whileSystem.out.printdoes 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
intanddouble.1.3.C.2 — The arithmetic operators consist of addition
+, subtraction-, multiplication*, division/, and remainder%. An arithmetic operation that uses twointvalues will evaluate to anintvalue. An arithmetic operation that uses at least onedoublevalue will evaluate to adoublevalue.❌ EXCLUSION — Expressions that result in special
doublevalues (e.g., infinities and NaN) are outside scope.
1.3.C.3 — When dividing numeric values that are both
intvalues, the result is only the integer portion of the quotient. When dividing numeric values that use at least onedoublevalue, the result is the quotient.1.3.C.4 — The remainder operator
%is used to compute the remainder when one numberais divided by another numberb.❌ EXCLUSION — The use of values less than 0 for
aand the use of values less than or equal to 0 forbis 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
doubleis outside scope.
Last updated
Was this helpful?