Front End Development Technology & Digital Applications 2 — Questions and Answers
Question 1: Which Web API allows front-end code to make HTTP requests to a server and handle responses asynchronously?
- XMLHttpRequest / Fetch API (Correct answer)
- WebSockets API
- IndexedDB API
- Service Worker API
Correct answer: XMLHttpRequest / Fetch API
XMLHttpRequest and the modern Fetch API are the standard browser APIs for making asynchronous HTTP requests to servers.
Question 2: What does the browser's 'same-origin policy' restrict?
- Scripts on one origin accessing resources from a different origin (Correct answer)
- CSS files loading fonts from external CDNs
- Images being displayed from third-party hosts
- HTML forms submitting to any URL
Correct answer: Scripts on one origin accessing resources from a different origin
The same-origin policy prevents scripts from one origin (scheme+host+port) from reading resources from a different origin without explicit CORS permission.
Question 3: Which storage mechanism stores data with no expiration date and persists even after the browser is closed?
- localStorage (Correct answer)
- sessionStorage
- Cookies with no max-age
- Memory cache
Correct answer: localStorage
localStorage persists data indefinitely across browser sessions until explicitly cleared, unlike sessionStorage which clears on tab close.
Question 4: A Progressive Web App (PWA) uses which technology to enable offline functionality?
- Service Workers (Correct answer)
- Web Workers
- IndexedDB
- WebAssembly
Correct answer: Service Workers
Service Workers act as a network proxy, intercepting requests and serving cached responses to enable offline functionality in PWAs.
Question 5: What is the primary purpose of a CDN (Content Delivery Network) in web applications?
- Serve assets from geographically closer servers to reduce latency (Correct answer)
- Compress JavaScript bundles before deployment
- Manage DNS records for domains
- Encrypt data between client and server
Correct answer: Serve assets from geographically closer servers to reduce latency
A CDN distributes static assets across edge servers worldwide so users download files from the nearest server, reducing latency.
Question 6: Which HTTP status code indicates that a resource has been permanently moved to a new URL?
- 301 Moved Permanently (Correct answer)
- 302 Found
- 304 Not Modified
- 307 Temporary Redirect
Correct answer: 301 Moved Permanently
301 Moved Permanently tells browsers and search engines that the resource has a new permanent URL and to update their records.
Question 7: What does WebAssembly (Wasm) enable in the browser?
- Running near-native speed binary code compiled from languages like C++ or Rust (Correct answer)
- Accessing the filesystem directly from JavaScript
- Rendering server-side templates in the browser
- Replacing CSS with programmatic styling
Correct answer: Running near-native speed binary code compiled from languages like C++ or Rust
WebAssembly is a binary instruction format that lets code compiled from C++, Rust, and other languages run at near-native speed in the browser.
Which Web API allows front-end code to make HTTP requests to a server and handle responses asynchronously?