{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6a82c64c-8d58-45ce-86e6-003e8576acb4",
   "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": "bdcd69e4-f631-4983-b473-3433a4132353",
   "metadata": {},
   "source": "## True or False\n\n**1.** Arrays in C# have a fixed size once created.\n\n```{dropdown} Answer\n**True** — Array size is set at creation; use `List<T>` for dynamic sizing.\n```\n\n**2.** The first element of a C# array is at index 1.\n\n```{dropdown} Answer\n**False** — C# arrays are zero-indexed; the first element is at index 0.\n```\n\n**3.** A jagged array in C# can have different numbers of columns per row.\n\n```{dropdown} Answer\n**True** — Jagged arrays (`int[][]`) allow rows of different lengths.\n```\n\n**4.** `array.Length` returns the total number of elements in a 1D array.\n\n```{dropdown} Answer\n**True** — `Length` gives the total element count.\n```\n\n**5.** You can store mixed data types (e.g., `int` and `string`) in a single typed array.\n\n```{dropdown} Answer\n**False** — A typed array is homogeneous; use `object[]` for mixed types.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "704900da-abd0-4e60-b14a-8eee2928bc11",
   "metadata": {},
   "source": "## Multiple Choice\n\n**1.** How do you declare an integer array of 5 elements in C#?\n\na) int array[5]  \nb) int[] array = new int[5]  \nc) array int[5]  \nd) int array = new[5]\n\n```{dropdown} Answer\n**b) int[] array = new int[5]** — C# uses `int[]` for the type and `new int[5]` to allocate.\n```\n\n**2.** What index accesses the last element of an array with 8 elements?\n\na) arr[8]  \nb) arr[7]  \nc) arr[-1]  \nd) arr[9]\n\n```{dropdown} Answer\n**b) arr[7]** — Last index = Length - 1 = 7.\n```\n\n**3.** Which loop construct is most natural for iterating all array elements?\n\na) while  \nb) do-while  \nc) foreach  \nd) goto\n\n```{dropdown} Answer\n**c) foreach** — `foreach` iterates elements without managing an index variable.\n```\n\n**4.** In `int[,] grid = new int[3, 4]`, how many elements does the grid hold?\n\na) 7  \nb) 3  \nc) 4  \nd) 12\n\n```{dropdown} Answer\n**d) 12** — 3 rows × 4 columns = 12 elements.\n```\n\n**5.** What happens when you access an array index outside its bounds?\n\na) Returns 0  \nb) Returns null  \nc) Throws IndexOutOfRangeException  \nd) Wraps around to the other end\n\n```{dropdown} Answer\n**c) Throws IndexOutOfRangeException** — Out-of-bounds access throws `IndexOutOfRangeException` at runtime.\n```\n\n"
  },
  {
   "cell_type": "markdown",
   "id": "8d0b98e3-b323-47c1-98cf-edc44ac78ec8",
   "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
}
