Skip to content
KALANBLON
Show contents

Chapter 3 of 6 · 10 min

Quiz: deciding

Conditions, switch, comparing texts and converting input: let's check that your Java program decides correctly. You need 70% correct answers.

Quiz

6 questions · pass mark: 70%

  1. 1.How do you test that a typed String, answer, is "yes"?

    One answer

  2. 2.What does this code display?

    One answer

    int n = 4;
    String size = switch (n) {
        case 1, 2 -> "small";
        case 3, 4 -> "medium";
        default -> "large";
    };
    IO.println(size);
  3. 3.What happens with Integer.parseInt("twelve")?

    One answer

  4. 4.Fill in the blank to remove the spaces around the input before converting it.

    Complete the code

    int n = Integer.parseInt(input.____());
  5. 5.Which conditions are true with int age = 30; boolean member = false;? (several answers)

    Several answers possible

  6. 6.Why does Double.parseDouble("2,5") fail?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.