← 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));
}
}
- A.30 10
- B.20 10
- C.20 0
- 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 →