Web Programming Certification — Questions and Answers
Question 1: What is the purpose of the HTTP POST method?
- Delete a resource
- Update a partial resource
- Retrieve a resource
- Submit data to create a new resource (Correct answer)
Correct answer: Submit data to create a new resource
The POST method submits data to the server to create a new resource, with the data included in the request body.
Question 2: Which keyboard key is the standard for activating a button or link that has keyboard focus?
- Shift
- Enter (Correct answer)
- Escape
- Tab
Correct answer: Enter
The Enter key activates focused links and buttons, and Space also activates buttons, making keyboard navigation possible without a mouse.
Question 3: What does the 'render-blocking' term mean in web performance?
- Resources like CSS or JavaScript that must load before the browser can render the page (Correct answer)
- JavaScript that prevents server rendering
- CSS animations that block user input
- Backend processes that block HTTP responses
Correct answer: Resources like CSS or JavaScript that must load before the browser can render the page
Render-blocking resources are files (usually CSS or synchronous JS in the <head>) that the browser must download and process before it can render any of the page content.
Question 4: Which CSS pseudo-class applies styles when the user hovers over an element?
- :visited
- :hover (Correct answer)
- :focus
- :active
Correct answer: :hover
The :hover pseudo-class applies styles to an element when the user's pointer is positioned over it without clicking.
Question 5: What is the purpose of `aria-live` regions in web accessibility?
- To display live video content accessibly
- To trigger real-time API calls
- To show a live chat feed on the page
- To announce dynamic content changes to screen reader users automatically (Correct answer)
Correct answer: To announce dynamic content changes to screen reader users automatically
`aria-live` regions instruct screen readers to automatically announce content changes within that region, such as status messages or search results.
Question 6: Which HTML tag is used to create a hyperlink?
- <a> (Correct answer)
- <link>
- <href>
- <url>
Correct answer: <a>
The <a> (anchor) element, combined with the href attribute, creates a hyperlink to another page or resource.
Question 7: In Angular, what is a component decorator (@Component) used for?
- To define metadata for an Angular component including its template and selector (Correct answer)
- To apply CSS styles
- To create HTTP interceptors
- To inject dependencies
Correct answer: To define metadata for an Angular component including its template and selector
The @Component decorator in Angular marks a class as a component and provides configuration metadata including the HTML template, CSS styles, and selector.
Question 8: In CSS, which value of 'position' removes an element from the normal document flow and positions it relative to the viewport?
- sticky
- absolute
- fixed (Correct answer)
- relative
Correct answer: fixed
position: fixed removes the element from document flow and fixes its position relative to the browser viewport, so it stays visible when scrolling.
Question 9: What is the purpose of the JavaScript 'event.preventDefault()' method?
- Bubbles the event to the parent element
- Removes all event listeners from the element
- Stops the event from firing
- Prevents the browser's default action for the event (Correct answer)
Correct answer: Prevents the browser's default action for the event
preventDefault() stops the browser's built-in behavior, like preventing a form from submitting or a link from navigating.
Question 10: What is event bubbling in JavaScript?
- A method to debounce events
- Creating animated bubble UI elements
- An event propagating from the target element up through its parent elements (Correct answer)
- Loading events asynchronously
Correct answer: An event propagating from the target element up through its parent elements
Event bubbling is the process where an event triggered on a child element propagates upward through ancestor elements in the DOM tree.
Question 11: What is the main purpose of a CSS preprocessor like SASS?
- To minify CSS for production
- To convert CSS to JavaScript
- To extend CSS with variables, nesting, and mixins for better maintainability (Correct answer)
- To automatically add vendor prefixes
Correct answer: To extend CSS with variables, nesting, and mixins for better maintainability
CSS preprocessors like SASS add programming features to CSS such as variables, nesting, mixins, and functions, which are then compiled down to standard CSS.
Question 12: What is the primary data format used in modern REST APIs?
- XML
- JSON (Correct answer)
- HTML
- CSV
Correct answer: JSON
JSON (JavaScript Object Notation) has become the dominant data format for REST APIs due to its lightweight nature, readability, and native support in JavaScript.
Question 13: What does the 'async' keyword do when added to a JavaScript function?
- Runs the function in a separate thread
- Forces the function to run synchronously
- Disables error handling in the function
- Makes the function always return a Promise (Correct answer)
Correct answer: Makes the function always return a Promise
An async function always returns a Promise and enables the use of 'await' inside it to pause execution until a Promise resolves.
Question 14: What does npm stand for?
- Node Program Module
- Node Package Manager (Correct answer)
- New Project Manager
- Network Package Module
Correct answer: Node Package Manager
npm stands for Node Package Manager, the default package manager for Node.js used to install, share, and manage JavaScript dependencies.
Question 15: Which WCAG success criterion requires that all functionality be available from the keyboard?
- 2.4.7 Focus Visible
- 1.4.3 Contrast Minimum
- 2.1.1 Keyboard (Correct answer)
- 1.1.1 Non-text Content
Correct answer: 2.1.1 Keyboard
WCAG 2.1.1 Keyboard requires that all functionality be operable through a keyboard interface without requiring specific timing for individual keystrokes.
Question 16: Which mechanism allows a web server to push data to the browser without the browser making a new request?
- URL parameters
- AJAX polling
- WebSockets (Correct answer)
- HTTP/1.1 keep-alive
Correct answer: WebSockets
WebSockets establish a persistent, full-duplex connection that lets the server send data to the client at any time.
Question 17: Which technique ensures focus is managed correctly when a modal dialog opens?
- Remove the modal from the DOM when closed
- Add role=dialog to the body element
- Move focus to the modal and trap it inside until the dialog closes (Correct answer)
- Set tabindex=-1 on all page elements
Correct answer: Move focus to the modal and trap it inside until the dialog closes
When a modal opens, focus must be moved inside it and trapped so keyboard users cannot accidentally interact with background content.
Question 18: What is insecure direct object reference (IDOR)?
- Using HTTP instead of HTTPS to reference assets
- Accessing resources by manipulating an identifier without authorization checks (Correct answer)
- Calling internal functions directly from JavaScript
- Directly embedding database credentials in HTML
Correct answer: Accessing resources by manipulating an identifier without authorization checks
IDOR occurs when an application exposes internal object IDs (like user IDs or file names) in URLs or params without verifying the requester has permission.
Question 19: Which CSS property is used to change the text color of an element?
- font-color
- text-color
- foreground
- color (Correct answer)
Correct answer: color
The color property in CSS sets the foreground color of text content and text decorations.
Question 20: What does the `SameSite=Strict` cookie attribute do?
- Sends the cookie only over HTTPS
- Prevents the cookie from being sent on cross-site requests (Correct answer)
- Encrypts the cookie value
- Restricts the cookie to a single path
Correct answer: Prevents the cookie from being sent on cross-site requests
SameSite=Strict prevents the browser from sending the cookie with any cross-site request, providing strong CSRF protection.
Question 21: What is the correct WCAG principle that requires content to be understandable to users?
- Robust
- Perceivable
- Operable
- Understandable (Correct answer)
Correct answer: Understandable
The WCAG 'Understandable' principle requires that information and the operation of the user interface must be understandable.
Question 22: What is the purpose of the useEffect hook in React?
- To perform side effects like data fetching, subscriptions, or DOM manipulation after rendering (Correct answer)
- To create visual effects and animations
- To manage Redux state
- To apply CSS effects to components
Correct answer: To perform side effects like data fetching, subscriptions, or DOM manipulation after rendering
The useEffect hook lets functional components perform side effects after rendering, such as fetching data, setting up subscriptions, or directly manipulating the DOM.
Question 23: What is the difference between a library and a framework in web development?
- Libraries work only in the browser; frameworks work on servers
- With a library you call its code; a framework calls your code (inversion of control) (Correct answer)
- Libraries use JavaScript; frameworks use TypeScript
- Libraries are free; frameworks cost money
Correct answer: With a library you call its code; a framework calls your code (inversion of control)
With a library you are in control and call its functions as needed, whereas a framework inverts control — you fill in the framework's structure and it calls your code.
Question 24: Recent data loss occurred on a web server that was set up to use TLS with AES-GCM-256, SHA-384, and ECDSA. Select the factor that is MOST likely to be the cause.
- Insufficient key bit length
- Unauthenticated encryption method
- Poor implementation (Correct answer)
- Weak cipher suite
Correct answer: Poor implementation
Even when strong cryptographic primitives like AES-GCM-256, SHA-384, and ECDSA are specified, data loss or security breaches can still occur due to poor implementation. This could involve vulnerabilities in the application logic, improper key management, misconfigurations, or human error in setting up and maintaining the system. A robust security posture requires not only strong algorithms but also flawless execution and operational practices.
Question 25: A developer stores passwords using MD5 without a salt. What is the primary risk?
- Passwords are stored in plain text
- MD5 requires a secret key to function
- The algorithm is too slow for production use
- Rainbow table attacks can crack hashes quickly (Correct answer)
Correct answer: Rainbow table attacks can crack hashes quickly
Unsalted MD5 hashes are vulnerable to precomputed rainbow table attacks because identical passwords produce identical hashes.
Question 26: What minimum color contrast ratio does WCAG 2.1 AA require for normal body text?
- 4.5:1 (Correct answer)
- 2:1
- 7:1
- 3:1
Correct answer: 4.5:1
WCAG 2.1 Level AA requires a contrast ratio of at least 4.5:1 for normal text to ensure it is readable by users with low vision.
Question 27: What does a 500 HTTP status code indicate?
- Bad request syntax
- Unauthorized access
- Internal Server Error (Correct answer)
- Request timeout
Correct answer: Internal Server Error
HTTP 500 Internal Server Error indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
Question 28: What is the DOM in web programming?
- A web server protocol
- The Document Object Model, a programming interface for HTML documents (Correct answer)
- A JavaScript testing framework
- A CSS preprocessor
Correct answer: The Document Object Model, a programming interface for HTML documents
The DOM (Document Object Model) is a programming interface that represents an HTML document as a tree of objects that can be manipulated with JavaScript.
Question 29: Which of the following commands, given a Date object named due date, sets the month to February?
- Due_date.setMonth(1); (Correct answer)
- Due_date.setMonth("Feb");
- Due_date.setMonth("February");
- Due_date.setMonth(2);
Correct answer: Due_date.setMonth(1);
In JavaScript, the `setMonth()` method of a Date object sets the month using a zero-based index. Therefore, January is 0, February is 1, March is 2, and so on. To set the month to February, you would pass the index `1` to the `setMonth()` method.
Question 30: What is the main difference between Vue.js and React?
- Vue requires Node.js; React runs in the browser only
- Vue uses a real DOM; React uses a virtual DOM
- Vue only supports TypeScript; React supports JavaScript
- Vue is an opinionated full framework; React is a UI library (Correct answer)
Correct answer: Vue is an opinionated full framework; React is a UI library
Vue.js is a progressive framework with more built-in features like routing and state management, while React is a focused UI library requiring additional libraries for a full stack.
Question 31: Which CSS unit is relative to the font-size of the root element?
- em
- px
- rem (Correct answer)
- vh
Correct answer: rem
The rem unit (root em) is relative to the font-size of the root <html> element, unlike em which is relative to the parent element.
Question 32: Which heading level should be used for the main title of a page's primary content area?
- <h3>
- <h2>
- <h1> (Correct answer)
- Any level as long as it is visually large
Correct answer: <h1>
Every page should have a single `<h1>` that describes the main topic of the page, providing a logical heading structure for screen reader navigation.
Question 33: What is the purpose of webpack in web development?
- A module bundler that combines JS, CSS, and other assets into optimized bundles (Correct answer)
- A CSS grid framework
- A unit testing framework
- A backend web server
Correct answer: A module bundler that combines JS, CSS, and other assets into optimized bundles
Webpack is a module bundler that processes and bundles JavaScript modules and other assets like CSS and images into optimized files for the browser.
Question 34: What is TypeScript's primary advantage over plain JavaScript?
- Faster execution speed
- Smaller file sizes
- Built-in HTTP client
- Static type checking that catches errors at compile time (Correct answer)
Correct answer: Static type checking that catches errors at compile time
TypeScript adds optional static typing to JavaScript, allowing type errors to be caught during development before the code runs in the browser.
Question 35: In web development, what is a Single Page Application (SPA)?
- A web app that loads once and dynamically updates content without full page reloads (Correct answer)
- An app that works only on mobile devices
- A website with only one HTML page of content
- A website with a single-column layout
Correct answer: A web app that loads once and dynamically updates content without full page reloads
A Single Page Application loads a single HTML document and dynamically rewrites the page content using JavaScript, avoiding full page reloads for navigation.
Question 36: Which header in an HTTP response tells the browser how long to cache the response before revalidating?
- Cache-Control (Correct answer)
- Last-Modified
- ETag
- Expires
Correct answer: Cache-Control
Cache-Control with directives like max-age=3600 is the modern standard for controlling caching behavior in both browsers and proxies.
Question 37: Which HTML element is used to define the structure of a web page's navigation links?
- <aside>
- <header>
- <menu>
- <nav> (Correct answer)
Correct answer: <nav>
The <nav> element is the semantic HTML5 element specifically designed to contain a set of navigation links.
Question 38: What does 'responsive web design' mean?
- Web design that adapts layout to different screen sizes using flexible grids and media queries (Correct answer)
- Websites that respond quickly to user clicks
- Websites with animated responses to user input
- Server-side rendering for fast responses
Correct answer: Web design that adapts layout to different screen sizes using flexible grids and media queries
Responsive web design is an approach where web pages use flexible grids, images, and CSS media queries to render well on all screen sizes from mobile to desktop.
Question 39: What HTML element defines a table row?
- <row>
- <tr> (Correct answer)
- <td>
- <th>
Correct answer: <tr>
The <tr> (table row) element defines a row of cells in an HTML table, containing <td> or <th> elements.
Question 40: What is the purpose of CSS media queries?
- To query the browser's CSS support
- To apply different CSS styles based on device characteristics like screen width (Correct answer)
- To load external CSS files conditionally
- To query a database from CSS
Correct answer: To apply different CSS styles based on device characteristics like screen width
CSS media queries allow you to apply different styles based on device characteristics such as screen width, height, or orientation, enabling responsive design.
Question 41: How would you access a virtual site you created at port 8000 in a browser?
- Http://localhost8000
- Http://localhost.8000
- Http://localhost:8000 (Correct answer)
- None of the above
Correct answer: Http://localhost:8000
When accessing a web server or virtual site running on your local machine (localhost) on a specific port, the standard URL format is `http://localhost:port_number`. The colon `:` correctly separates the hostname from the port number, making `http://localhost:8000` the proper way to access a site listening on port 8000.
Question 42: What is returned by the prompt method if a dialog box is displayed, text is entered, and the OK button is clicked?
- None of the above
- A string value (Correct answer)
- A null value
- A Boolean value
Correct answer: A string value
The `prompt()` method in JavaScript displays a dialog box that asks the user for input. If the user enters text and clicks 'OK,' the method returns the entered text as a string value. If the user clicks 'Cancel' or enters nothing, it returns `null` or an empty string, respectively.
Question 43: What does the CSS box model consist of from inside to outside?
- content, border, padding, margin
- margin, border, padding, content
- content, padding, border, margin (Correct answer)
- padding, content, border, margin
Correct answer: content, padding, border, margin
The CSS box model layers are, from innermost to outermost: content, padding, border, then margin.
Question 44: What does the HTML alt attribute on an <img> tag provide?
- Image title shown on hover
- Image dimensions
- Image file format
- Alternative text for accessibility and when image fails to load (Correct answer)
Correct answer: Alternative text for accessibility and when image fails to load
The alt attribute provides alternative text that is displayed when the image cannot be loaded and read by screen readers for accessibility.
Question 45: Which CSS property controls the stacking order of positioned elements?
- z-index (Correct answer)
- depth
- layer
- stack-order
Correct answer: z-index
The z-index property specifies the stack order of a positioned element, with higher values appearing in front of lower values.
Question 46: Which CSS selector targets an element with a specific id attribute?
- .myId
- @myId
- *myId
- #myId (Correct answer)
Correct answer: #myId
The # symbol is used in CSS to select elements by their id attribute, making #myId target the element with id='myId'.
Question 47: Information about the session status is kept in the $_Session _______
- Autoglobal (Correct answer)
- Function
- Cookie
- Script
Correct answer: Autoglobal
In PHP, `$_SESSION` is a superglobal (also known as an autoglobal) array used to store session variables. Superglobals are built-in variables that are always available in all scopes throughout a script, making `$_SESSION` the mechanism for managing session-specific data across multiple page requests for a single user.
Question 48: Which CSS property controls the transparency of an HTML element?
- filter: blur()
- opacity (Correct answer)
- display
- visibility
Correct answer: opacity
The opacity property sets the transparency level of an element from 0 (fully transparent) to 1 (fully opaque).
Question 49: In HTML, what is the correct way to create an unordered list?
- <list><item>Item</item></list>
- <dl><dd>Item</dd></dl>
- <ul><li>Item</li></ul> (Correct answer)
- <ol><li>Item</li></ol>
Correct answer: <ul><li>Item</li></ul>
An unordered list uses the <ul> element containing <li> (list item) elements, rendering as bulleted items by default.
Question 50: What is the purpose of preloading resources in web performance?
- To tell the browser to fetch critical resources earlier in the page load lifecycle (Correct answer)
- To cache resources for offline use
- To load resources after user interaction
- To load resources on other pages proactively
Correct answer: To tell the browser to fetch critical resources earlier in the page load lifecycle
Preloading instructs the browser to fetch important resources (fonts, critical CSS, key images) as early as possible in the page load to avoid delays when they're later needed.
Question 51: In React, what is the useState hook used for?
- Connecting to a database
- Fetching data from APIs
- Adding and managing local state in functional components (Correct answer)
- Routing between pages
Correct answer: Adding and managing local state in functional components
The useState hook allows functional components to declare and manage local state variables, returning the current state and a function to update it.
Question 52: Which element should wrap the primary content of a page to create a main landmark for accessibility?
- <article>
- <div role="content">
- <section>
- <main> (Correct answer)
Correct answer: <main>
The `<main>` element creates a main landmark region, signaling to screen readers that this is the primary content of the page.
Question 53: In HTML, which attribute is used to link an external CSS file to a web page?
- rel
- src
- href (Correct answer)
- link
Correct answer: href
The href attribute in a <link> tag specifies the URL of the external CSS stylesheet to be applied to the document.
Question 54: What is the output of typeof null in JavaScript?
- 'undefined'
- 'object' (Correct answer)
- 'boolean'
- 'null'
Correct answer: 'object'
typeof null returns 'object', which is a well-known bug in JavaScript that has been retained for backward compatibility.
Question 55: What does 'defense in depth' mean in web security?
- Using the deepest encryption algorithm available
- Auditing code only at the final release stage
- Layering multiple independent security controls so no single failure compromises the system (Correct answer)
- Relying on a single, very strong firewall
Correct answer: Layering multiple independent security controls so no single failure compromises the system
Defense in depth layers controls (WAF, input validation, parameterized queries, least privilege) so that bypassing one layer doesn't give full access.
Question 56: What is the purpose of the HTML <meta charset='UTF-8'> tag?
- Defines the page author
- Sets the page language
- Sets the viewport size
- Specifies the character encoding for the document (Correct answer)
Correct answer: Specifies the character encoding for the document
The charset meta tag declares the character encoding used in the HTML document, with UTF-8 supporting virtually all characters and symbols.
Question 57: Which keyword is used to declare a block-scoped variable in modern JavaScript?
- let (Correct answer)
- local
- def
- var
Correct answer: let
The let keyword declares a block-scoped variable that is limited to the block, statement, or expression in which it is used.
Question 58: What is 'event bubbling' in JavaScript?
- Creating multiple events simultaneously
- Events firing before the DOM is loaded
- Animations triggered by user events
- An event propagating from the target element up through its parent elements (Correct answer)
Correct answer: An event propagating from the target element up through its parent elements
Event bubbling means an event triggered on a child element propagates upward through ancestor elements in the DOM tree.
Question 59: What CSS property controls the space between an element's border and its content?
- padding (Correct answer)
- border-gap
- spacing
- margin
Correct answer: padding
The padding property defines the space between an element's content and its border, inside the element.
Question 60: In web server configuration, what does a 'virtual host' allow you to do?
- Virtualize the network interface for load balancing
- Create isolated file system containers
- Host multiple websites on a single server using different domain names (Correct answer)
- Run multiple operating systems simultaneously
Correct answer: Host multiple websites on a single server using different domain names
Virtual hosting lets one physical server respond to requests for multiple domains by routing based on the Host header or IP address.
Question 61: Which JavaScript method converts a JSON string into a JavaScript object?
- JSON.decode()
- JSON.convert()
- JSON.stringify()
- JSON.parse() (Correct answer)
Correct answer: JSON.parse()
JSON.parse() takes a JSON-formatted string as input and returns the corresponding JavaScript object, array, or value.
Question 62: Which CSS display value makes an element start on a new line and take up the full width available?
- block (Correct answer)
- inline-block
- inline
- flex
Correct answer: block
The block display value causes the element to generate a block-level box, starting on a new line and stretching to fill the container.
Question 63: What is the difference between authentication and authorization in web APIs?
- Authentication is only for APIs; authorization is for websites
- Authentication determines permissions; authorization verifies identity
- Authentication verifies identity; authorization determines permissions (Correct answer)
- They are the same thing
Correct answer: Authentication verifies identity; authorization determines permissions
Authentication verifies who you are (identity), while authorization determines what you are allowed to do (permissions) once your identity is confirmed.
Question 64: Which hashing algorithm among the following is the LEAST secure?
- DES
- RIPEMD
- SHA1
- MD5 (Correct answer)
Correct answer: MD5
MD5 (Message-Digest Algorithm 5) is a cryptographic hash function that has been found to be vulnerable to collision attacks, meaning it's possible to find two different inputs that produce the same hash output. This weakness makes it unsuitable for security-critical applications like password storage or digital signatures, as it can be exploited. While SHA1 also has known weaknesses, MD5 is generally considered the least secure among the listed hashing algorithms for modern security applications.
Question 65: What does HTTP status code 401 indicate?
- Resource not found
- Server error
- Unauthorized — authentication required (Correct answer)
- Forbidden — access denied
Correct answer: Unauthorized — authentication required
HTTP 401 Unauthorized indicates that the request lacks valid authentication credentials and the client must authenticate to get the requested response.
Question 66: What HTML attribute makes a form input field required before submission?
- mandatory
- notnull
- validate
- required (Correct answer)
Correct answer: required
The required attribute is a boolean HTML attribute that prevents form submission if the field is empty.
Question 67: What is the correct HTML5 doctype declaration?
- <!DOCTYPE HTML5>
- <!DOCTYPE html PUBLIC>
- <!DOCTYPE html> (Correct answer)
- <html doctype='5'>
Correct answer: <!DOCTYPE html>
The HTML5 doctype is simply <!DOCTYPE html>, which is a simplified version compared to older HTML doctypes.
Question 68: What will the test variable be after the following line has been executed if the count variable has a value of 1? Test variable = (count == 1)? "errors": "error";
- Error
- Count
- Errors (Correct answer)
- 1
Correct answer: Errors
This is a ternary operator, which is a shorthand for an if-else statement. The condition `(count == 1)` is evaluated first. Since `count` has a value of `1`, the condition `1 == 1` is true, so the value before the colon, which is "errors", is assigned to the `test` variable.
Question 69: What does the spread operator (...) do when used with an array?
- Sorts the array
- Expands array elements into individual values (Correct answer)
- Deletes array elements
- Reverses the array
Correct answer: Expands array elements into individual values
The spread operator expands an iterable like an array into its individual elements, useful for copying, merging arrays, or passing elements as function arguments.
Question 70: Which CSS property makes an element invisible but still occupies space in the layout?
- hidden: true
- opacity: 0
- display: none
- visibility: hidden (Correct answer)
Correct answer: visibility: hidden
visibility: hidden hides an element visually while keeping its space in the document layout, unlike display:none which removes it from the flow.
Web Programming Certification
A comprehensive assessment of web programming skills covering HTML/CSS, JavaScript, frontend frameworks, REST APIs, and web accessibility standards. Aligns with W3Schools Modern Web Developer and CIW Web Design Specialist competency frameworks.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds