Skip to main content

Learning about Code Structure

Section 1.3 Rule 1) Conjoining Conditions

Please watch the video to learn when to conjoin conditions with &&, then answer the following questions. Enlarge the window to view the code examples clearly. If needed, click the settings icon in the video player and set the quality to 1080p for better clarity.
Figure 1.3.1. Conjoining conditions with && part 1

Checkpoint 1.3.2.

Consider the following Java function and fill in the blank parts in the truth table.
public static String message(int age, boolean didConsent) {
    if (age >= 18 && didConsent) {
        return "You can participate in the study";
    }
    return "Sorry, you cannot participate";
}
age >= 18 didConsent Output
true true "You can participate in the study"
true --Blank 1--- "Sorry, you cannot participate"
false ---Blank 2--- "Sorry, you cannot participate"
false false ---Blank 3---
Write your responses here:
Blank 1:
Blank 2:
Blank 3:
You have attempted 1 of 3 activities on this page.