Skip to main content

Section 2.28 Assessment: Boolean Logical Operators

Subgoals for evaluating an assignment statement.

  1. Determine resultant data type of expression
  2. Update variable for pre operators based on side effect
  3. Solve arithmetic equation, operator precedence
  4. Is the Left Hand Side (LHS) of the assignment statement a variable? Check the data type of the value on right hand side (RHS) against data type of LHS variable.
  5. Update variable for post operators based on side effect

Exercises Exercises

    1.

      Q1: Given the following, what value is stored in variable answer?
      int x = 5;
      int y = 3;
      int z = 1;
      boolean answer;
      answer = (x < y) && (z < y);
      
    • true
    • false

    2.

      Q2: Given the following, what value is stored in variable answer?
      int x = 5;
      int y = 3;
      int z = 1;
      boolean answer;
      answer = (x < y) || !(z < y);
      
    • true
    • false

    3.

      Q3: Given the following, what value is stored in variable answer?
      int x = 5;
      int y = 3;
      int z = 1;             
      boolean answer;
      answer = (x <= 5) && (y >= 2);
      
    • true
    • false

    4.

      Q4: Given the following, what value is stored in variable answer?
      int x = 5;
      int y = 3;
      int z = 1;
      boolean answer;
      answer = (y == z) || (z == x);
      
    • true
    • false

    5.

      Q5: Given the following, what value is stored in variable answer?
      int x = 5;
      int y = 3;
      int z = 1;
      boolean answer;
      answer = (x <= 3) || ((z <= y) && (z == 1));
      
    • true
    • false
You have attempted of activities on this page.