Unit 6: Web Application Development and Deployment - Practice Quiz

CSE326 — Internet Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the main purpose of debugging?

Debugging Techniques Easy
A. To compress image files
B. To register a domain
C. To find and fix errors
D. To publish a website

2 What does a breakpoint do during debugging?

Debugging Techniques Easy
A. Reloads the web page
B. Pauses code execution
C. Uploads files to GitHub
D. Deletes unused code

3 Which browser developer tool displays messages produced by console.log()?

Browser Developer Tools Easy
A. Elements panel
B. Storage panel
C. Console panel
D. Network panel

4 Which browser developer tool is commonly used to inspect HTML elements and CSS styles?

Browser Developer Tools Easy
A. Sources panel
B. Network panel
C. Performance panel
D. Elements panel

5 Which JavaScript statement is used to handle an exception?

Error Handling Easy
A. if...else
B. for...of
C. switch...case
D. try...catch

6 What is the purpose of the finally block in JavaScript error handling?

Error Handling Easy
A. Creates a new exception
B. Repeats the failed operation
C. Stops the browser process
D. Runs code after handling

7 Which JavaScript method attaches an event handler to an HTML element?

Interactive User Interface Development Easy
A. addEventListener()
B. getAttribute()
C. querySelector()
D. createElement()

8 Which event usually occurs when a user presses and releases a mouse button on an element?

Interactive User Interface Development Easy
A. resize
B. click
C. load
D. submit

9 Where does client-side JavaScript normally execute?

Client-Side Application Design Easy
A. In the user's browser
B. In a DNS server
C. In a mail server
D. In a database server

10 What is the DOM in a client-side web application?

Client-Side Application Design Easy
A. A network security rule
B. A repository access setting
C. A page object structure
D. A server storage format

11 Why are functions used to organize JavaScript code?

Code Organization Easy
A. To configure network routers
B. To group reusable instructions
C. To purchase domain names
D. To increase image dimensions

12 What is a common benefit of placing CSS in a separate stylesheet?

Code Organization Easy
A. Improved style maintainability
B. Automatic database creation
C. Built-in user authentication
D. Faster domain registration

13 Which action commonly reduces the loading time of a web page?

Website Performance Fundamentals Easy
A. Increasing file sizes
B. Using more redirects
C. Compressing large images
D. Adding duplicate scripts

14 What is browser caching used for?

Website Performance Fundamentals Easy
A. Reusing downloaded resources
B. Renaming all source files
C. Deleting every page request
D. Blocking every network response

15 What is a GitHub repository primarily used to store?

GitHub Repository Management Easy
A. Browser cookies and sessions
B. Monitor settings and drivers
C. Project files and history
D. Domain records and routes

16 What does a Git commit represent?

GitHub Repository Management Easy
A. A purchased web domain
B. A saved project snapshot
C. A deleted user account
D. A running browser process

17 What type of website is GitHub Pages commonly used to host?

Website Hosting using GitHub Pages Easy
A. Email service
B. Static website
C. Database server
D. Desktop application

18 Which file commonly serves as the home page of a GitHub Pages site?

Website Hosting using GitHub Pages Easy
A. README.md
B. .gitignore
C. package.json
D. index.html

19 Why should an image include meaningful alternative text?

Web Development Best Practices Easy
A. To create a repository
B. To configure web hosting
C. To improve accessibility
D. To execute JavaScript code

20 How can GitHub Copilot assist a web developer?

Improving Web Applications using GitHub Copilot Easy
A. By suggesting code
B. By repairing hardware
C. By registering domains
D. By replacing browsers

21 A JavaScript function produces the correct result for most inputs but fails when the input array is empty. Which debugging technique is most appropriate for identifying the cause?

Debugging Techniques Medium
A. Move the function into a separate stylesheet
B. Minify the JavaScript file and run the application again
C. Add a breakpoint and inspect variables when the empty array is processed
D. Disable browser caching for all application resources

22 An event handler appears to run twice whenever a button is clicked. What should a developer investigate first?

Debugging Techniques Medium
A. Whether the page title is defined in the document
B. Whether the stylesheet contains duplicate selectors
C. Whether the button uses a semantic HTML element
D. Whether the same listener is registered more than once

23 A page sends a form submission, but the server returns an unexpected response. Which browser developer tools panel provides the most useful initial evidence?

Browser Developer Tools Medium
A. Elements panel for examining computed styles
B. Sources panel for editing local JavaScript
C. Network panel for examining the request and response
D. Application panel for examining stored cookies

24 A heading has the correct CSS class but displays with the wrong color. Which developer tools feature best identifies the rule overriding its color?

Browser Developer Tools Medium
A. The storage table in the Application panel
B. The call stack in the JavaScript debugger
C. The computed styles view in the Elements panel
D. The timing chart in the Network panel

25 A client-side application calls an API with fetch(). Which approach correctly handles an HTTP 404 response?

Error Handling Medium
A. Use finally to convert the response into valid data
B. Catch only syntax errors raised while parsing the script
C. Check response.ok and throw an error when it is false
D. Assume every resolved promise contains successful data

26 An application displays data loaded from a remote service. What is the best user-facing behavior when the request fails?

Error Handling Medium
A. Write the full exception stack trace into the page
B. Show a clear error state with an option to retry
C. Remove the entire interface until the user refreshes
D. Leave the loading indicator visible without further changes

27 A list contains many dynamically added delete buttons. Which event-handling strategy is most maintainable?

Interactive User Interface Development Medium
A. Add an inline click attribute to every generated button
B. Attach a new window listener whenever an item is added
C. Poll all delete buttons repeatedly with a timer
D. Use one delegated click listener on the list container

28 A custom dropdown can be opened with a mouse but not operated with a keyboard. Which change most directly improves its accessibility?

Interactive User Interface Development Medium
A. Store the selected value in session storage
B. Increase the animation duration when the menu opens
C. Add keyboard controls and manage focus during interaction
D. Replace text labels with background images

29 A single-page application must update the displayed products whenever its filter state changes. Which design is most appropriate?

Client-Side Application Design Medium
A. Read the current filters only from visible label text
B. Store each product only in unrelated global variables
C. Reload the complete HTML document after every selection
D. Treat the state as the source used to render the product view

30 Two components need the same API data and currently send identical requests whenever the page loads. Which design change best reduces duplication?

Client-Side Application Design Medium
A. Fetch the data in a shared service and reuse the result
B. Give each component a different copy of the endpoint URL
C. Convert both requests from asynchronous to synchronous
D. Place the response data inside a CSS custom property

31 A JavaScript file mixes API requests, DOM updates, validation, and storage operations in one large function. What is the best refactoring approach?

Code Organization Medium
A. Rename the function without changing its internal structure
B. Split the responsibilities into focused functions or modules
C. Duplicate the function for each page that uses it
D. Move all statements into one global event listener

32 Several modules need the same date-formatting behavior. Where should that behavior be placed?

Code Organization Medium
A. In separate copied functions inside each module
B. In a hidden HTML element read by every module
C. In a CSS rule imported by the relevant pages
D. In a shared utility module with a documented interface

33 A page's largest visible image delays the Largest Contentful Paint measurement. Which change is most likely to improve the result?

Website Performance Fundamentals Medium
A. Add more JavaScript before the image element
B. Optimize its size and serve an appropriate modern format
C. Load the image through a delayed click handler
D. Encode the image at a larger intrinsic resolution

34 A website loads a large JavaScript bundle that contains code used only on an admin page. Which optimization best addresses this issue?

Website Performance Fundamentals Medium
A. Load the admin code only when that route is requested
B. Rename the bundle to use a shorter file name
C. Store the entire bundle in a JavaScript variable
D. Place the bundle at the beginning of the HTML file

35 A developer wants to add a new feature without destabilizing the repository's main branch. Which workflow is most appropriate?

GitHub Repository Management Medium
A. Delete the commit history before starting the feature
B. Create a separate repository for every source file
C. Develop on a feature branch and open a pull request
D. Commit unfinished changes directly to the main branch

36 A merge conflict occurs because two branches changed the same lines. What should the developer do?

GitHub Repository Management Medium
A. Keep both file versions without examining their behavior
B. Resolve the conflicting content, test it, and commit the result
C. Remove the conflicted file from version control permanently
D. Delete both branches and recreate the repository

37 A project site is published at https://example.github.io/shop/, but its stylesheet is requested from https://example.github.io/styles.css and returns 404. Which change is appropriate?

Website Hosting using GitHub Pages Medium
A. Move the stylesheet into the repository's issue tracker
B. Change the stylesheet extension from .css to .html
C. Reference the stylesheet through a local disk path
D. Use a project-aware relative path such as ./styles.css

38 A GitHub Pages site displays index.html, but server-side PHP code appears as text or does not execute. What is the reason?

Website Hosting using GitHub Pages Medium
A. GitHub Pages requires PHP files to use lowercase names
B. GitHub Pages executes PHP only from the default branch
C. GitHub Pages serves static content and does not run PHP
D. GitHub Pages requires PHP code to be placed in CSS files

39 A registration form currently validates required fields only with JavaScript in the browser. What should be added before production deployment?

Web Development Best Practices Medium
A. Client-side validation based only on text color
B. Server-side validation of all submitted values
C. A separate stylesheet for each form control
D. Longer placeholder text for every input field

40 GitHub Copilot suggests a function that builds SQL using direct string interpolation from a form value. What is the best response?

Improving Web Applications using GitHub Copilot Medium
A. Hide the interpolation inside a helper with a shorter name
B. Replace it with a parameterized query and review the behavior
C. Use it unchanged if the function passes a syntax check
D. Accept it because generated code is automatically security-tested

41 A production exception maps to a source line that cannot produce the observed error. Local debugging with the same source code works correctly. What should be verified first?

Debugging Techniques Hard
A. Whether the source map contains only relative paths rather than absolute paths
B. Whether the browser has JavaScript disabled for the production domain
C. Whether the deployed bundle and source map came from the same build artifact
D. Whether all production functions have descriptive names instead of minified names

42 A timing-sensitive interface bug disappears whenever a normal breakpoint is added. Which technique is most appropriate for collecting evidence while minimizing disruption to execution timing?

Debugging Techniques Hard
A. Replace all promises with blocking loops during the investigation
B. Insert synchronous alert dialogs before every asynchronous callback
C. Disable browser caching and single-step through every executed statement
D. Use conditional logpoints and timestamped performance marks around state transitions

43 A cross-origin fetch sends a custom X-Report-ID header. DevTools shows an OPTIONS request returning 403, while JavaScript receives only TypeError: Failed to fetch. Which change addresses the underlying failure?

Browser Developer Tools Hard
A. Configure the server to accept the preflight and allow the origin and custom header
B. Parse the failed response body before checking the response status code
C. Add Access-Control-Allow-Origin as a request header in the browser code
D. Set the request mode to no-cors so JavaScript can read the complete response

44 Successive heap snapshots show increasing numbers of detached modal DOM trees. The retaining path leads from a document-level event listener to a closure that references each modal. What is the most direct correction?

Browser Developer Tools Hard
A. Hide closed modals with CSS and retain their listeners for later reuse
B. Force garbage collection immediately after setting each modal's display to none
C. Remove or abort the document listener and release modal references during cleanup
D. Clone each modal before removal so its event listeners are not preserved

45 The code fetch('/api/item/42').then(r => r.json()).then(render).catch(showError) displays a generic parsing error when the server returns an HTML 404 page. Which revision preserves the HTTP failure meaning?

Error Handling Hard
A. Check r.ok, throw an error containing r.status, and parse only valid responses
B. Treat every resolved fetch promise as successful regardless of HTTP status
C. Call r.json() twice and use the second rejection as the HTTP error
D. Move catch before then(render) so it can inspect the original response

46 A dashboard loads four independent widgets using Promise.all. One optional widget rejects, causing the dashboard to discard the other three successful results. Which design best supports partial rendering while retaining error information?

Error Handling Hard
A. Wrap the requests in one try block and ignore any resulting exception
B. Use Promise.race and render whichever widget settles before the others
C. Use Promise.any and duplicate its first fulfilled value across all widgets
D. Use Promise.allSettled and process fulfilled and rejected outcomes separately

47 A list uses one delegated click listener, and each action button contains nested icons. Items may also be inserted dynamically. Which handler logic most reliably identifies a valid action button?

Interactive User Interface Development Hard
A. Use event.target.parentElement and assume the button is exactly one level higher
B. Use event.target.closest('[data-action]') and verify the result belongs to the list
C. Use list.querySelector('[data-action]') and execute the first matching action
D. Use event.currentTarget.matches('[data-action]') and read the list's action

48 A modal visually overlays the page, but keyboard users can tab into background controls and lose their previous focus when it closes. Which behavior provides the strongest accessible interaction model?

Interactive User Interface Development Hard
A. Focus the close button, leave the background interactive, and remove all focus indicators
B. Move focus into the modal, disable the Escape key, and restore focus to the document root
C. Move focus into the modal, contain tab navigation, inert the background, and restore focus
D. Place aria-hidden on the modal, preserve document tab order, and focus the page body

49 A search interface sends a request after each query. Occasionally, a slow response for an older query overwrites the results of a newer query. Which design most robustly prevents stale commits?

Client-Side Application Design Hard
A. Delay rendering until every request created during the session has completed
B. Sort completed responses by HTTP status and render the first successful response
C. Cache every response and always render the response with the largest payload
D. Assign each request a sequence token and commit only the latest token's response

50 An application stores todos, completedTodos, and completedCount as separately mutable state. After several updates, the three values disagree. Which redesign best preserves consistency?

Client-Side Application Design Hard
A. Update all three values through unrelated event listeners running in registration order
B. Store only the canonical todos and derive completed items and counts when needed
C. Persist all three values independently and reconcile them only when the page reloads
D. Freeze the completed count while allowing both todo arrays to change independently

51 Modules orders.js and payments.js import each other through a shared barrel file. Depending on import order, one module observes an uninitialized binding. What is the best structural remedy?

Code Organization Hard
A. Duplicate both modules' implementations so that neither file needs an import
B. Move shared contracts into a dependency-free module and inject cross-module services
C. Add more re-exports to the barrel so the runtime chooses a stable initialization order
D. Convert every named export into a default export while retaining the dependency cycle

52 Importing a utility module in a unit test unexpectedly registers DOM listeners and starts a timer because the module executes setup at top level. Which refactoring best improves reuse and test isolation?

Code Organization Hard
A. Retain top-level setup but increase the timer delay so tests usually complete first
B. Move the side effects into an explicit initialization function called by the application entry point
C. Copy the utility functions into the test suite to avoid importing the production module
D. Catch all top-level exceptions and silently continue when no document object exists

53 The Largest Contentful Paint element is a hero background image declared in a stylesheet that is discovered late. The image is above the fold and currently lazy-loaded by script. Which change most directly improves its discovery and priority?

Website Performance Fundamentals Hard
A. Increase the image dimensions and store it under a filename without a cache extension
B. Inline every application script before the stylesheet so image discovery occurs later
C. Prefetch the image after the load event and keep script-controlled lazy loading
D. Preload the hero as an image in the document head and avoid lazy-loading that image

54 A deployment uses content-hashed JavaScript filenames, but returning users sometimes keep an old HTML document that references assets removed by the new deployment. Which caching policy best limits this failure?

Website Performance Fundamentals Hard
A. Revalidate HTML frequently and cache hashed assets as long-lived immutable resources
B. Give HTML and hashed assets the same long expiration without revalidation
C. Cache HTML immutably for one year and disable caching for hashed JavaScript files
D. Disable caching for HTML and all static assets on every production request

55 A repository accepts pull requests from forks. A workflow using pull_request_target checks out the contributor's head commit and then runs its build script with repository secrets available. What is the safest redesign?

GitHub Repository Management Hard
A. Use a read-only pull_request workflow without secrets to execute untrusted contribution code
B. Approve every fork workflow automatically because GitHub masks secrets in console output
C. Move secrets into source files so the build no longer accesses the Actions secret store
D. Keep the privileged trigger but hide secret values by disabling workflow command echoing

56 A faulty merge commit has already been pulled by many developers from a protected main branch. The project must undo its changes while preserving shared history. Which action is appropriate?

GitHub Repository Management Hard
A. Revert the merge with the correct mainline parent and merge the revert through review
B. Force-push main to the commit immediately preceding the faulty merge
C. Delete the local branch and ask every developer to reconstruct the commit graph
D. Rebase all commits after the merge and force-push the rewritten branch

57 A GitHub Pages project site is published at https://example.github.io/catalog/. The HTML loads, but assets requested from /assets/app.js return 404, and client routes omit /catalog/. What configuration is required?

Website Hosting using GitHub Pages Hard
A. Set the build asset base and client router basename to /catalog/
B. Add query parameters to every asset URL and leave the router rooted at /
C. Rename the repository to assets and configure the router basename as /app/
D. Set the build asset base to / and remove the repository name from all URLs

58 A single-page application hosted on GitHub Pages works when navigating internally, but directly opening /reports/2025 returns the Pages 404. Server-side rewrite rules and redirect scripts are not allowed. Which routing strategy resolves this constraint?

Website Hosting using GitHub Pages Hard
A. Use deeper history routes so GitHub Pages can infer the nearest application directory
B. Store the route in a cookie while continuing to request /reports/2025 from the server
C. Use hash-based routes such as /#/reports/2025 so the server requests the entry page
D. Send a custom rewrite header from the browser before requesting every client route

59 An application converts untrusted Markdown comments to HTML and inserts the result with innerHTML. The Markdown library permits embedded HTML. Which defense most directly prevents stored DOM-based XSS while preserving supported formatting?

Web Development Best Practices Hard
A. Encode the Markdown before parsing and trust every HTML node produced afterward
B. Sanitize the generated HTML with a maintained allowlist sanitizer before insertion
C. Remove only <script> strings and permit all event attributes and URL schemes
D. Validate comments solely in the browser and store the resulting HTML unchanged

60 GitHub Copilot suggests authentication middleware that calls a JWT decode function and trusts the resulting role claim without verifying the token. What is the correct response before adopting the suggestion?

Improving Web Applications using GitHub Copilot Hard
A. Verify signature, allowed algorithm, issuer, audience, and time claims with a trusted library
B. Accept it because decoding a JWT necessarily validates its signature and claims
C. Add client-side obfuscation so attackers cannot discover the role claim's name
D. Store the decoded role in local storage and compare it during later requests