Back-End Development An Intro to Full-Stack Development 5 — Questions and Answers
Question 1: What is JWT (JSON Web Token) primarily used for in full-stack applications?
- Compressing JSON payloads for faster transmission
- Stateless authentication by encoding user claims in a signed token (Correct answer)
- Encrypting database passwords before storage
- Validating HTML form inputs on the front-end
Correct answer: Stateless authentication by encoding user claims in a signed token
JWTs encode user identity and claims in a signed token that the server can verify without maintaining session state.
Question 2: What is 'continuous integration' (CI) in the context of full-stack development?
- Merging database schemas automatically at runtime
- Automatically building and testing code whenever changes are pushed (Correct answer)
- A deployment pattern where updates roll out to one server at a time
- A method of continuously syncing front-end assets to a CDN
Correct answer: Automatically building and testing code whenever changes are pushed
CI pipelines automatically build and run tests on every code push to catch regressions early.
Question 3: Which of the following is a primary benefit of containerizing a full-stack application with Docker?
- It automatically scales the app based on CPU usage
- It ensures consistent environments across development, testing, and production (Correct answer)
- It replaces the need for a database in production
- It compiles JavaScript to native machine code
Correct answer: It ensures consistent environments across development, testing, and production
Docker containers bundle the app and its dependencies so the same image runs identically on any machine.
Question 4: In full-stack development, what does 'horizontal scaling' mean?
- Upgrading a single server with more CPU and RAM
- Adding more server instances to distribute the load (Correct answer)
- Splitting a monolith into microservices
- Increasing the number of database columns in a table
Correct answer: Adding more server instances to distribute the load
Horizontal scaling adds more machines running the same application to handle increased traffic.
Question 5: What is the role of a reverse proxy like Nginx in a full-stack deployment?
- To compile server-side TypeScript during deployment
- To sit in front of app servers and forward client requests to them (Correct answer)
- To run database migrations before the app starts
- To generate SSL certificates on demand
Correct answer: To sit in front of app servers and forward client requests to them
A reverse proxy receives client requests and forwards them to back-end application servers, handling SSL termination and load balancing.
Question 6: Which of the following is a common way to prevent SQL injection attacks in back-end code?
- Disabling database logging
- Using parameterized queries or prepared statements (Correct answer)
- Storing SQL queries in environment variables
- Hashing all database column names before querying
Correct answer: Using parameterized queries or prepared statements
Parameterized queries separate SQL code from user-supplied data, preventing malicious input from altering query logic.
Question 7: What is the purpose of a `.gitignore` file in a full-stack project?
- To list all contributors who should be ignored in code reviews
- To specify files and directories Git should not track or commit (Correct answer)
- To define which npm packages are optional dependencies
- To configure which files the web server should deny access to
Correct answer: To specify files and directories Git should not track or commit
`.gitignore` tells Git to exclude specified files (like `node_modules/` and `.env`) from version control.
What is JWT (JSON Web Token) primarily used for in full-stack applications?