Skip to main content
00

Computer Science Fundamentals

Boolean Logic

1/5

An AND gate outputs 1 in which case?

Pick one answer

Text version of this lesson

AND, OR and NOT — the three operations every circuit and every condition is built from.

  1. Question 1

    An AND gate outputs 1 in which case?

    Options

    • When at least one input is 1
    • Only when both inputs are 1
    • Only when both inputs are 0
    • When the inputs differ
    Show answer and explanation

    Answer: Only when both inputs are 1

    Why: AND demands both conditions at once, so a single 0 on either input forces the output to 0. Option A describes OR, and option D describes XOR. In code this is the same operator that makes a guard clause require every check to pass.

    Hint: Read it as the everyday word "and".

  2. Question 2

    How many rows does a truth table with three inputs have?

    Show answer and explanation

    Answer: 8 rows

    Why: Three independent inputs give 2 × 2 × 2 = 8 combinations, from 000 to 111. Truth tables double with every added input, which is why exhaustive testing of a condition with twenty flags is already out of reach at over a million rows.

    Hint: Each input is either 0 or 1, independently.

  3. Question 3

    Which expression is equivalent to NOT (A AND B)?

    Options

    • (NOT A) AND (NOT B)
    • (NOT A) OR (NOT B)
    • A OR B
    • NOT A AND B
    Show answer and explanation

    Answer: (NOT A) OR (NOT B)

    Why: De Morgan's law says a negated AND becomes an OR of negations. "Not both" is true whenever at least one of them fails, which is exactly (NOT A) OR (NOT B). Option A says neither holds, a strictly stronger claim. Applying this law is how tangled conditions get simplified in real code.

    Hint: Negate each part and flip the connective between them.

  4. Question 4

    Which gate outputs 1 exactly when its two inputs are different?

    Options

    • AND
    • OR
    • XOR
    • NOT
    Show answer and explanation

    Answer: XOR

    Why: XOR is exclusive OR: true for 0-1 and 1-0, false for 0-0 and 1-1. Ordinary OR also returns 1 when both inputs are 1, which is the difference between them. XOR is what powers parity checks, simple encryption and the addition step inside a binary adder.

    Hint: Plain OR also accepts the case where both inputs are 1.

  5. Question 5

    Which single gate type can be wired together to build every other gate?

    Options

    • AND
    • OR
    • NAND
    • XOR
    Show answer and explanation

    Answer: NAND

    Why: Feeding the same signal into both inputs of a NAND gives NOT. A NAND followed by that NOT gives AND, and negating both inputs of a NAND gives OR — so everything else follows. Plain AND and OR can never produce a negation, so they cannot be universal. Chip designers exploit this by manufacturing vast fields of one gate type.

    Hint: You need a gate that can produce a NOT on its own.