{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2fb9eb57-7531-4f93-861e-35f98c391aa4",
   "metadata": {},
   "source": "# Preview Questions\n\nComplete these questions **before** class to prepare for the chapter.\nUse the dropdowns to check your answers.\n"
  },
  {
   "cell_type": "markdown",
   "id": "89dc53f8-0783-44a5-b0e4-71f059c5908e",
   "metadata": {},
   "source": "## True or False\n\n**1.** An `else` clause is required for every `if` statement.\n\n```{dropdown} Answer\n**False** — `else` is optional; `if` alone is valid.\n```\n\n**2.** The `&&` operator returns `true` only when both conditions are true.\n\n```{dropdown} Answer\n**True** — `&&` is logical AND — both sides must be true.\n```\n\n**3.** A `switch` statement in C# can only test integer values.\n\n```{dropdown} Answer\n**False** — C# `switch` works with `int`, `string`, `enum`, and more.\n```\n\n**4.** The `!` operator negates a boolean value.\n\n```{dropdown} Answer\n**True** — `!true` evaluates to `false` and vice versa.\n```\n\n**5.** Compound boolean expressions can always replace nested `if` statements.\n\n```{dropdown} Answer\n**True** — Nested conditions can be flattened using `&&` and `||`.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "0ef7b8ec-03c7-49da-aa6a-9c938838a35c",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** Which operator represents logical OR in C#?\n\na) |  \nb) ||  \nc) OR  \nd) or\n\n```{dropdown} Answer\n**b) ||** — `||` is the short-circuit logical OR; `|` is the bitwise OR.\n```\n\n**2.** In a `switch` statement, which keyword exits the current case?\n\na) exit  \nb) end  \nc) break  \nd) stop\n\n```{dropdown} Answer\n**c) break** — `break` prevents fall-through to the next case.\n```\n\n**3.** Which expression is `true` when `x = 5`?\n\na) x > 10 && x < 3  \nb) x > 3 && x < 10  \nc) x > 10 || x < 3  \nd) !(x == 5)\n\n```{dropdown} Answer\n**b) x > 3 && x < 10** — 5 > 3 is true AND 5 < 10 is true, so the whole expression is true.\n```\n\n**4.** What does `condition ? a : b` return when `condition` is `false`?\n\na) condition  \nb) a  \nc) b  \nd) null\n\n```{dropdown} Answer\n**c) b** — The ternary operator returns `b` on false.\n```\n\n**5.** Which statement best describes an `if-else if-else` chain?\n\na) All branches always execute  \nb) Only the first matching branch executes  \nc) The last branch always executes  \nd) Branches execute in parallel\n\n```{dropdown} Answer\n**b) Only the first matching branch executes** — Execution stops at the first condition that evaluates to true.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "fd53109d-76c0-4d53-83a3-2e98eb0cf0d3",
   "metadata": {},
   "source": "```{rubric} Footnotes\n```\n"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
