levo

Defining Data: Types, Variables and Classes

Arithmetic operators and expressions

  • 3 things to know
  • AS Unit 1

Overview

The five arithmetic operators, integer against floating point division, the remainder operator and the sign it takes, increment and decrement in prefix and postfix form, and compound assignment.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is the value of 9 / 2 * 2 in integer arithmetic, and why?

Key term

int i = 3; int r = i++ + ++i; — what values do r and i hold?

Key term

Which five arithmetic operators does Java provide, and what does each do?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Which five arithmetic operators does Java provide, and what does each do?

    Model answer

    Java provides plus for addition, minus for subtraction, an asterisk for multiplication, a solidus for division and a percent sign for the remainder after division.

  2. 2

    What does the remainder operator return? Give the value of 17 % 5.

    Model answer

    The remainder operator returns what is left after integer division, so 17 % 5 is 2, because 17 is three fives with 2 remaining.

  3. 3

    How is the remainder operator used to test whether an integer is even?

    Model answer

    An integer n is even exactly when n % 2 equals 0, because an even number leaves no remainder when divided by two.

  4. 4

    What is the value of −7 % 3 in Java, and why does the result carry that sign?

    Model answer

    The value is −1, because Java gives the remainder the sign of the left operand: −7 is −2 threes with −1 remaining.

  5. 5

    What is integer division? Give the value of 17 / 5.

    Model answer

    Integer division divides and discards any fractional part, so 17 / 5 is 3 rather than 3.4.

  6. 6

    What is the value of 9 / 2 * 2 in integer arithmetic, and why?

    Model answer

    The value is 8, because 9 / 2 is evaluated first as integer division giving 4, and 4 multiplied by 2 is 8; the discarded remainder is never recovered.

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.