🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Test Design Techniques: all 10 questions

Quiz: Test Design Techniques · Question 3 of 10

What does this print? (code)

What does this print?

public class Main {
    static int discount(boolean student, boolean coupon) {
        if (student) return 20;
        if (student && coupon) return 30;
        if (coupon) return 10;
        return 0;
    }
    public static void main(String[] args) {
        System.out.println(discount(true, true) + " " + discount(false, true));
    }
}
  1. A.30 10
  2. B.20 10
  3. C.20 0
  4. D.30 0
Answer & explanation

Correct answer: 20 10

The student check runs first, so the student-with-coupon rule can never return 30. Rule R1 of the decision table catches this bug.

Can you get the rest right without peeking?

Take the timed Quiz: Test Design Techniques quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →