QUIZ: Topic 6 - GEN AI Total Questions: 10 Instructions: Choose the most correct option (A, B, C or D) for each question. Check your answers using the Answer Key at the end. 1. Which statement best describes GitHub Copilot compared with ChatGPT? A) Copilot lives inside your IDE and can see your open files and project context. B) Copilot runs in a browser tab and only sees whatever text you paste into it. C) Copilot runs fully offline on your laptop with no internet connection. D) Copilot is strongest at big-picture design discussions and comparing approaches. 2. In the C.O.D.E. prompt framework, writing "Java 17, plain Java SE, no external libraries" belongs to which part? A) Objective B) Context C) Details and constraints D) Expected output format 3. Which Copilot Chat slash command is used to generate Javadoc documentation drafts? A) /explain B) /fix C) /doc D) /tests 4. In the spec-first (two-step) generation pattern, what do you ask for in Step 1? A) The complete method body with all the logic B) Only the method signature plus its Javadoc, then stop and wait for approval C) A full set of unit tests for the method D) The compiler errors in the current file 5. Which change is a true refactor (same behaviour, better shape) according to the session? A) Changing the return type of calculateGst from double to BigDecimal B) Replacing string concatenation inside a loop with a StringBuilder C) Adding a null guard that returns an empty string instead of throwing D) Removing the trailing ", " so the built output string no longer ends with a separator 6. A prompt says the delivery fee is waived when the subtotal is above Rs. 500, but never states what happens at exactly Rs. 500. Which prompt failure mode is this? A) Overloaded B) Contextless C) Underspecified D) Unverifiable 7. An AI assistant suggests the code String out = text.reverse();. What is the fastest reliable way to detect the hallucination? A) Ask the same assistant again in a fresh chat and trust it if it repeats the answer B) Run the program, because only runtime testing can catch a bad method C) Compile the code; it fails with "cannot find symbol" because String has no reverse() method in Java D) Benchmark the method and keep it if it runs fast enough 8. A generated loop sums the scores of an array of length 4 using the condition i <= scores.length. What happens when the code runs? A) It works correctly and prints the right sum B) It throws ArrayIndexOutOfBoundsException because index 4 is out of range; valid indices are 0 to 3 C) It throws NullPointerException D) It enters an infinite loop 9. In the expression (attended / total) * 100, both values are int. What value does attendancePercent(45, 50) produce inside the method? A) 90.0 B) 0.9 C) 0 D) 45.0 10. Before pasting a stack trace into a public chat LLM, what must you do? A) Nothing; a stack trace is diagnostic output and contains nothing confidential B) Replace any database connection string and customer personal data with placeholders or dummy values C) Paste it in a private browser tab so it will not be stored D) Paste it and delete the conversation immediately afterwards ANSWER KEY 1. A) Copilot is the in-editor tool that sees your open files and project context, while ChatGPT lives in a browser and needs the internet; Copilot is weakest at big-picture design, so the other options are false. 2. B) C stands for Context, and stating your Java version, plain Java SE and no external libraries is context that keeps the generated code usable in your project. 3. C) /doc generates Javadoc documentation drafts; /explain explains selected code, /fix proposes a correction, and /tests generates unit tests. 4. B) The spec-first pattern asks only for the signature plus Javadoc and stops to wait; reviewing four lines is cheaper than rejecting a full implementation later. 5. B) Swapping string concatenation for a StringBuilder keeps the output identical (same behaviour, better shape); the other options change the return type, the exception behaviour, or the returned string. 6. C) This is the underspecified failure mode: the prompt left the boundary decision at exactly Rs. 500 to the model instead of stating it. 7. C) Compiling is the fastest lie detector: String has no reverse() method, so it fails with "cannot find symbol" (the fix is new StringBuilder(text).reverse().toString()). 8. B) With i <= scores.length the loop tries index 4 on a 4-element array; valid indices are 0 to 3, so it throws ArrayIndexOutOfBoundsException. 9. C) Both operands are int, so 45 / 50 truncates to 0 and 0 * 100 is 0 (returned as 0.0 in a double method): an integer-division bug the compiler never flags. 10. B) The session treats a public LLM like a public forum: connection strings and personal data must be redacted with placeholders, and you remain accountable for the output.