levo

Defining Data: Types, Variables and Classes

Operator precedence and evaluation order

  • 3 things to know
  • AS Unit 1

Overview

Operator precedence and value of true || false && false.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is operator precedence?

Key term

What is associativity, and which way do the arithmetic operators associate in Java?

Key term

What is the value of true || false && false, and in which order are the two operators applied?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is operator precedence?

    Model answer

    Operator precedence is the set of rules that decides which operator in an expression is applied first when no parentheses say otherwise.

  2. 2

    List the main groups of Java operators in order of precedence, highest first.

    Model answer

    Highest are the unary operators, then multiplication, division and remainder, then addition and subtraction, then the relational operators, then equality, then logical AND, then logical OR, and lowest of all assignment.

  3. 3

    What is the value of 2 + 3 * 4, and in what order are the operators applied?

    Model answer

    The result is 14, because multiplication has higher precedence than addition, so 3 * 4 is evaluated to 12 and 2 is then added.

  4. 4

    What is the value of (2 + 3) * 4, and how do the parentheses change the result?

    Model answer

    The result is 20, because parentheses force the addition first, giving 5, which is then multiplied by 4.

  5. 5

    What is associativity, and which way do the arithmetic operators associate in Java?

    Model answer

    Associativity decides the order when two operators of equal precedence meet, and the arithmetic operators associate from left to right.

  6. 6

    Which common Java operator associates from right to left? Explain what a = b = 5 does.

    Model answer

    Assignment associates from right to left, so a = b = 5 first stores 5 in b and then stores the result of that assignment in a, leaving both at 5.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Defining Data: Types, Variables and Classes, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.