Web Technologies MCQs (Set-4)

Difficulty: Hard

Which response header can restrict allowed script sources?

A Cache-Control
B Content-Type
C Content-Security-Policy
D Accept-Encoding

When displaying untrusted text, which API is safer?

A Use textContent
B Use innerHTML directly
C Append to a script
D Build markup by concatenation

To verify request source, what does an anti-CSRF token help establish?

A Response uses TLS
B Cookie is persistent
C Origin supports CORS
D Request came from trusted form

Why does an HTTPS certificate matter to a browser?

A Compresses response content
B Authenticates server identity
C Hides URL path
D Prevents all phishing

After a successful WebSocket upgrade, which status should the server return?

A 200 OK
B 204 No Content
C 304 Not Modified
D 101 Switching Protocols

How does a WebSocket handshake begin?

A DNS TXT query
B TLS certificate request
C HTTP Upgrade request
D HTML form submission

For repeated updates to the same target, which HTTP method is idempotent?

A PUT
B POST
C CONNECT
D PATCH

In HTTP terms, what does idempotency mean for repetition?

A Identical response bytes
B Same intended effect
C No network transfer
D Always returns 200

Where is an HttpOnly cookie unavailable?

A HTTPS requests
B Same-site requests
C Server headers
D JavaScript APIs

Which cookie attribute requires secure-channel transmission?

A Secure
B Path
C Domain
D Priority

For a service worker, what does its scope limit?

A Defines CSS inheritance
B Sets cookie lifetime
C Limits controlled URL paths
D Names an HTTP method

How does the preload resource hint affect fetching?

A Waits for user click
B Fetches resource early
C Loads after page close
D Queries DNS only

Code splitting can reduce which initial loading cost?

A HTML parse errors
B DNS query count
C CSS specificity
D Initial transfer size

Among Core Web Vitals, which measures layout instability?

A LCP
B INP
C CLS
D TTFB

Which metric measures render time of the largest contentful element?

A Largest content render time
B First input delay
C Layout shift score
D Interaction count

Which metric replaced First Input Delay as a Core Web Vital?

A CLS
B INP
C LCP
D FCP

How can an ETag help a cache validator?

A Encrypt cached bytes
B Set browser origin
C Choose content language
D Compare representation versions

HTTP 412 denotes which condition?

A Precondition failed
B Authentication required
C Resource created
D Range unsatisfied

In transit, which TLS property protects data from passive reading?

A Compression
B Caching
C Encryption
D Minification

How can Subresource Integrity help with external scripts?

A Blocks every third party
B Checks expected file hash
C Encrypts cookies
D Validates HTML structure

Shadow DOM can encapsulate which component details?

A HTTP headers
B DNS records
C Form methods
D DOM and styles

Which ARIA feature announces dynamic content changes?

A aria-live region
B role=button
C aria-hidden
D alt text

Which HTML attribute can suppress referrer details?

A crossorigin
B fetchpriority
C referrerpolicy
D autocomplete

When does a classic deferred script execute?

A Before HTML parsing
B After parsing completes
C After window unload
D During DNS lookup

Why should a CORS response vary by Origin when reflecting it?

A Prevent TLS handshakes
B Disable client scripts
C Normalize request methods
D Separate cache variants