AI Coding Assistants interview questions

27 questions from the AI Coding Assistants: Use Them Well and Review Them Hard course, each with the correct answer and an explanation. Try to answer before you open the answer.

What Coding Assistants Are

1. Which kind of assistant can edit many files and run your tests?

  1. Inline completion only
  2. A spell-checker
  3. An agent mode
  4. A syntax highlighter
Show answer

Answer: An agent mode

Agents combine file access, editing and command execution in a loop.

Lesson: Autocomplete, Chat and Agents

2. Why can an assistant give code that looks right but is wrong?

  1. It predicts plausible code and does not verify it by running it
  2. It always copies from the internet
  3. It refuses to use tests
  4. It cannot read code
Show answer

Answer: It predicts plausible code and does not verify it by running it

Plausibility is what it optimises; correctness has to be checked separately.

Lesson: How They Work

3. Which task needs the most careful human review?

  1. Renaming a variable
  2. Formatting a JSON file
  3. Adding a code comment
  4. Authentication and cryptography code
Show answer

Answer: Authentication and cryptography code

Security-critical code fails silently and the cost of a mistake is high.

Lesson: Strengths and Limits

4. What is the best way to compare two coding assistants?

  1. Read only advertisements
  2. Give both the same real task from your project and compare the results
  3. Pick the cheapest
  4. Pick whichever is newest
Show answer

Answer: Give both the same real task from your project and compare the results

A real task shows quality, context handling and review effort on your own code.

Lesson: Choosing and Configuring a Tool

Prompting for Code

5. Which detail most improves a bug-fix request?

  1. Saying "please" three times
  2. The exact error message and the relevant files
  3. A longer greeting
  4. Capital letters
Show answer

Answer: The exact error message and the relevant files

Concrete evidence lets the assistant reason about the real problem instead of guessing.

Lesson: Context Is Everything

6. Why list edge cases in the prompt?

  1. It slows the editor
  2. It makes the answer longer
  3. Edge cases do not matter
  4. So the assistant does not have to guess how to handle them
Show answer

Answer: So the assistant does not have to guess how to handle them

Explicit cases remove ambiguity and double as a checklist for testing.

Lesson: Requirements and Constraints

7. What is the benefit of writing tests before asking for code?

  1. Success becomes checkable and the assistant has a target
  2. Tests make code longer only
  3. Assistants refuse to code otherwise
  4. It removes the need to read code
Show answer

Answer: Success becomes checkable and the assistant has a target

Tests define "correct" up front, so you verify results with evidence rather than impressions.

Lesson: Tests First, Code Second

8. Why ask for a feature in small steps?

  1. It is required by Git
  2. Assistants cannot write large code
  3. Small changes are easier to review, test and undo
  4. It saves no time ever
Show answer

Answer: Small changes are easier to review, test and undo

Large, unreviewed diffs hide mistakes; small verified steps keep you in control.

Lesson: Small Steps and Iteration

Everyday Workflows

9. How should you treat an assistant's explanation of code?

  1. As useless
  2. As always correct
  3. As a helpful hypothesis to verify against the code
  4. As a legal document
Show answer

Answer: As a helpful hypothesis to verify against the code

Explanations speed up understanding, but you confirm them by reading or running the code.

Lesson: Explaining Unfamiliar Code

10. What is a good way to keep generated code consistent with your project?

  1. Point at an existing file as the pattern to follow
  2. Never mention conventions
  3. Use random naming
  4. Ask for the longest code possible
Show answer

Answer: Point at an existing file as the pattern to follow

A concrete example of your style gives the assistant something specific to imitate.

Lesson: Writing Functions and Boilerplate

11. Why avoid accepting a fix you do not understand?

  1. It makes the editor slower
  2. Fixes are always wrong
  3. Git forbids it
  4. It may hide the real bug while removing the symptom
Show answer

Answer: It may hide the real bug while removing the symptom

Understanding the cause is how you know the problem is truly solved.

Lesson: Debugging with an Assistant

12. What protects behaviour during an AI-assisted refactor?

  1. Hoping nothing changed
  2. A passing test suite before and after
  3. A longer prompt
  4. Deleting old tests
Show answer

Answer: A passing test suite before and after

Tests detect accidental behaviour changes that a diff alone may not reveal.

Lesson: Refactoring and Migrating

Tests and Documentation

13. How can you check that a generated test is meaningful?

  1. Count how many lines it has
  2. Break the code on purpose and see if it fails
  3. Check that it has a long name
  4. Delete it
Show answer

Answer: Break the code on purpose and see if it fails

A meaningful test fails when the behaviour it protects is broken.

Lesson: Generating Tests That Mean Something

14. What is the main risk of AI-written documentation?

  1. It deletes comments
  2. It is always too short
  3. It cannot use Markdown
  4. It may describe behaviour the code does not actually have
Show answer

Answer: It may describe behaviour the code does not actually have

Fluent text can be inaccurate, so verify each claim against the code.

Lesson: Docs, Comments and Commit Messages

Reviewing AI-Written Code

15. An assistant suggests `npm install fast-json-validator-pro`. What should you do first?

  1. Check that the package is real and reputable
  2. Install it immediately
  3. Install it globally
  4. Add it to production first
Show answer

Answer: Check that the package is real and reputable

The name may be invented or malicious, so verify it on the registry before installing.

Lesson: Hallucinated APIs and Packages

16. Which input is most likely to expose a missing-check bug in `average(nums)`?

  1. A list of 1000 numbers
  2. A list of strings only
  3. An empty list
  4. A very long variable name
Show answer

Answer: An empty list

Empty input is a classic boundary case that triggers division by zero.

Lesson: Subtle Logic Bugs

17. How do you prevent SQL injection in generated database code?

  1. Hide the database
  2. Build SQL with string formatting
  3. Use parameterised queries
  4. Use shorter variable names
Show answer

Answer: Use parameterised queries

Placeholders keep user input as data, never as part of the SQL command.

Lesson: Security Flaws in Generated Code

18. What should you review: the assistant's summary or the diff?

  1. The diff itself
  2. Only the summary
  3. Neither
  4. The commit time
Show answer

Answer: The diff itself

The summary can omit or misdescribe changes; the diff is the truth about what will ship.

Lesson: A Practical Review Checklist

Privacy, Licensing and Safety

19. You pasted an API key into an assistant chat. What is the right response?

  1. Delete the chat and hope
  2. Paste it again to check
  3. Do nothing
  4. Rotate or revoke the key
Show answer

Answer: Rotate or revoke the key

Once sent, you cannot be sure where it was stored, so the key must be replaced.

Lesson: Secrets and Private Code

20. Which is a sensible habit regarding licences and generated code?

  1. Ignore all policies
  2. Follow your organisation's policy and be cautious about long verbatim blocks
  3. Assume everything is public domain
  4. Remove all comments
Show answer

Answer: Follow your organisation's policy and be cautious about long verbatim blocks

Policy compliance and care with verbatim code reduce legal and ethical risk.

Lesson: Licensing and Ownership

21. Why run an agent on a separate branch?

  1. Branches make the agent smarter
  2. To discard everything easily if the result is bad
  3. Agents refuse to work on main
  4. It deletes the tests
Show answer

Answer: To discard everything easily if the result is bad

A separate branch isolates risky changes and makes rollback trivial.

Lesson: Safe Use of Agents and Injection

Learning and Working in Teams

22. Which habit best builds your own skill?

  1. Asking for the full solution immediately
  2. Avoiding all practice
  3. Copying answers without reading
  4. Attempting first, then asking for a hint or review
Show answer

Answer: Attempting first, then asking for a hint or review

Effort followed by feedback is how problem-solving ability develops.

Lesson: Learning Without a Crutch

23. Who is responsible for AI-generated code in a pull request?

  1. The author who submits it
  2. The AI tool vendor
  3. Nobody
  4. The reviewer only
Show answer

Answer: The author who submits it

Whoever commits code owns it, however it was produced.

Lesson: Adopting Assistants in a Team

Putting It Together

24. In the case study, when are the tests written?

  1. After merging
  2. Never
  3. Before the implementation, so success is checkable
  4. Only if the build fails
Show answer

Answer: Before the implementation, so success is checkable

Defining success first gives both you and an agent a clear target to verify against.

Lesson: Case Study: Adding a Feature

25. An assistant's generated tests all pass. What should you still do?

  1. Nothing, green means correct
  2. Delete the tests
  3. Break the code on purpose to confirm the tests can fail
  4. Ask the assistant to say they are fine
Show answer

Answer: Break the code on purpose to confirm the tests can fail

Green tests only help if they would turn red when the code is wrong.

Lesson: Revision: Cheat Sheet and Self-Check

26. Which of these should never be pasted into an assistant prompt?

  1. A production database password
  2. A public function signature
  3. A generic error message
  4. A question about syntax
Show answer

Answer: A production database password

Credentials must stay out of prompts because prompts leave your machine.

Lesson: Revision: Cheat Sheet and Self-Check

27. You do not understand a block of generated code. What is the best next step?

  1. Commit it, it probably works
  2. Delete the tests
  3. Hide it in a comment
  4. Ask the assistant to explain it and verify by running it, or simplify it
Show answer

Answer: Ask the assistant to explain it and verify by running it, or simplify it

You are responsible for every line you commit, so understand it or replace it with something you do.

Lesson: Revision: Cheat Sheet and Self-Check

← Back to the course