Skip to main content

Section 1.25 Assessment: Boolean Relational Operators

Subsection 1.25.1 Subgoals for evaluating an assignment statement

  1. Determine resultant data type of expression

  2. Update variable for pre-increment or pre-decrement operators (side effect)

  3. Evaluate arithmetic expression according to operator precedence

  4. If an assignment statement (=), is Left Hand Side (LHS) a variable? Check data type of value against data type of variable.

  5. Update variable for post-increment or post-decrement operators (side effect)

Exercises 1.25.2 Exercises

1.

    Q1: Given the following, what value is stored in variable answer?

    int x = 5, y = 3, z = 1;

    boolean answer;

    answer = x <= z;

  • true

  • false

2.

    Q2: Given the following, what value is stored in variable answer?

    int x = 5, y = 3, z = 1;

    boolean answer;

    answer = y >= z;

  • true

  • false

3.

    Q3: Given the following, what value is stored in variable answer?

    int x = 5, y = 3, z = 1;

    boolean answer;

    answer = x > z + y;

  • true

  • false

4.

    Q4: Given the following, what value is stored in variable answer?

    int x = 5, y = 3, z = 1;

    boolean answer;

    answer = z < y - z;

  • true

  • false

5.

    Q5: Given the following, what value is stored in variable answer?

    int x = 5, y = 3, z = 1;

    boolean answer;

    answer = ((x * y) + (x * z)) != ((z * x) + (y * x));

  • true

  • false

You have attempted of activities on this page.