E-Commerce Development Introduction to E-commerce Development 4 — Questions and Answers
Question 1: Which approach best prevents SQL injection attacks in an e-commerce product search feature?
- Disabling the search feature entirely
- Using parameterized queries or prepared statements (Correct answer)
- Storing all product names in uppercase
- Limiting search results to 10 items
Correct answer: Using parameterized queries or prepared statements
Parameterized queries separate SQL code from user-supplied data, preventing malicious input from altering the query structure.
Question 2: What is the purpose of an inventory reservation system during checkout?
- To display estimated delivery dates
- To temporarily hold stock for a customer while they complete payment, preventing overselling (Correct answer)
- To automatically reorder products from suppliers
- To calculate shipping weight
Correct answer: To temporarily hold stock for a customer while they complete payment, preventing overselling
Reserving inventory during checkout ensures two customers cannot simultaneously purchase the last unit of a product.
Question 3: Which caching strategy is most appropriate for caching product prices that change frequently?
- Cache forever with no expiration
- Short TTL cache with invalidation on price update events (Correct answer)
- Cache only on the client browser
- Never cache prices
Correct answer: Short TTL cache with invalidation on price update events
A short TTL combined with event-driven cache invalidation keeps prices fresh while still reducing database load.
Question 4: What is cross-site scripting (XSS) in the context of an e-commerce review system?
- Sharing product reviews across multiple storefronts
- An attack where malicious scripts are injected into user-generated content and executed in victims' browsers (Correct answer)
- A technique for cross-linking related products
- A method to import reviews from third-party platforms
Correct answer: An attack where malicious scripts are injected into user-generated content and executed in victims' browsers
XSS allows attackers to inject scripts into pages viewed by other users, potentially stealing session tokens or redirecting customers.
Question 5: Why is lazy loading important for e-commerce product image galleries?
- It prevents users from downloading images
- It defers loading off-screen images until the user scrolls to them, improving initial page load time (Correct answer)
- It compresses images automatically on the server
- It loads all images in parallel at maximum resolution
Correct answer: It defers loading off-screen images until the user scrolls to them, improving initial page load time
Lazy loading reduces the initial payload of a product page by only fetching images as they enter the viewport.
Question 6: Which of the following is a benefit of using webhooks in an e-commerce integration?
- They allow the server to push real-time event notifications to external services without polling (Correct answer)
- They replace the need for a REST API
- They automatically generate shipping labels
- They encrypt all outbound traffic
Correct answer: They allow the server to push real-time event notifications to external services without polling
Webhooks enable event-driven integrations by sending HTTP callbacks when events like 'order placed' or 'payment received' occur.
Question 7: What is the primary function of a product configurator on an e-commerce site?
- To configure server settings for the storefront
- To allow customers to customize product options (size, color, material) and see a live price update (Correct answer)
- To configure payment gateway credentials
- To generate automated product descriptions
Correct answer: To allow customers to customize product options (size, color, material) and see a live price update
A product configurator lets shoppers select variants and options dynamically, recalculating price and availability in real time.
Which approach best prevents SQL injection attacks in an e-commerce product search feature?