# Revision and Interview Questions — Elixir & Phoenix

Source: https://www.geekswithgeeks.com/en/elixir-phoenix/s-revision

> Recall Elixir and Phoenix concepts quickly for exams and interviews.

## Cheat sheet

**Platform**: Elixir on the BEAM (Erlang VM); lightweight isolated processes, message passing, preemptive scheduling, distribution, hot code upgrades; Erlang interop. **Tools**: Mix (`mix new --sup`, `deps.get`, `test`, `format`), Hex, HexDocs, IEx (`h`, `i`, `iex -S mix`), Livebook. **Types**: integers, floats (`/` returns a float, `div`/`rem`), atoms, UTF-8 binary strings, charlists, lists, tuples, maps (`%{m | k: v}`), keyword lists; immutability and rebinding. **Matching**: `=` match operator, destructuring, pin `^`, `_`, MatchError. **Functions**: `def`/`defp`, name and arity, multi-clause with guards, defaults `\\`, `fn` and `&` capture, module attributes, `@doc`, `@spec`. **Pipelines**: `|>`, Enum (eager), Stream (lazy), `for` comprehensions. **Control**: `case`, `cond`, `if`, `with`/`else`. **Data**: structs, `@enforce_keys`, protocols vs behaviours. **Errors**: `{:ok, _}`/`{:error, _}`, bang functions, `raise`/`rescue`, let it crash. **OTP**: `spawn`, `send`, `receive`, links, monitors, GenServer (`call`, `cast`, `handle_info`), Supervisors (one_for_one, one_for_all, rest_for_one), DynamicSupervisor, Registry, Task and `async_stream`, ETS, Agent. **Macros**: `quote`, `unquote`, `use` and `__using__`. **Phoenix**: endpoint, router, pipelines, plugs, controllers, HEEx, `~p`, contexts, `action_fallback`, `phx.gen.auth`; **Ecto**: Repo, schemas, changesets, migrations, queries with `^`, preload, Multi; **LiveView**, PubSub, Channels, Presence; ExUnit; releases and `runtime.exs`.

## Common interview questions

Answer each with a short code example.

```text
1. What makes BEAM processes different from OS threads?
2. Explain the match operator and the pin operator.
3. Why does Elixir use {:ok, value} and {:error, reason} tuples?
4. What is the difference between GenServer.call and GenServer.cast?
5. Explain supervision strategies and "let it crash".
6. Protocols vs behaviours: when do you use each?
7. Enum vs Stream: when does laziness matter?
8. How does with simplify error handling?
9. What is ETS and when would you use it instead of a GenServer?
10. How does Phoenix LiveView work under the hood?
11. What is an Ecto changeset, and why is it not part of the schema struct?
12. Why should you avoid String.to_atom on user input?
```

## Talk about failure

Elixir interviews often focus on failure: what happens when a process crashes, how supervisors restart it, what state is lost and how the design keeps the system available. Explaining that clearly shows real OTP understanding.

**Quiz:** Which construct restarts crashed processes in an Elixir application?

- [ ] A protocol
- [ ] A changeset
- [ ] A plug
- [x] A supervisor

*Answer:* A supervisor. Supervisors monitor children and restart them according to their strategy.
