Multiple Choice

  1. What has the same result as counter++?

  2. What is the result of 89 % 4?

  3. What is the result of number after int number = 7.0 / 2.0;?

  4. What is a valid value for a boolean?

  5. Suppose you want to store the age of your dog in a variable (the years). What would be the most obvious datatype for this?

  6. What is the result of 11 / 5?

  7. What is the correct definition of a primitive datatype?

  8. Which of the data types below is not a primitive datatype?

  9. What is the result of 83 % 4?

  10. What is the resulting value in q?

    int x = 5;
    int y = 2;
    double q = (double) x / y;
  11. What is the most correct and complete definition of a variable?

  12. Why are the operators +, -, *, /, ... called binary operators?

  13. Which of the following code blocks makes use of compound operators?

    // Code block A
    int x = ( 25 / 3 ) * (15 % 4);
    // Code block B
    int z = 0;
    for (int i = 0; i < 5; i++) {
      int y = i + 5;
      z++;
    }
    // Code block C
    double vatPercent = 21;
    double priceTag = 55;
    double vat = priceTag * vatPercent / 100;
    // Code block D
    int x = 32;
    int y = 88;
    
    while (x <= 1000) {
      x += 5;
    }
  14. Which of the following code snippets will not result in the value of b incrementing with 1?

    int x = 15;
    int b = 3;
    x = b++;
    int x = 15;
    int b = 3;
    x += (++b);
    int x = 15;
    int b = 3;
    x = (b + 1);
    int x = 15;
    int b = 3;
    b += 1;

Last updated