Quiz Space

Modern Application Development II · Quiz 2 · 12 Apr 2026 · January 2026 term

Question 14: Consider a scenario involving localStorage, Promise chai…

Question 14

+3 marksOne or more correct options

Consider a scenario involving localStorage, Promise chains, and Vue lifecycle hooks:
Scenario: A user authentication system where: On app initialization, the app checks localStorage for a stored user token• If a token exists, it validates the token asynchronously (via a Promise)• Based on validation, different UI components are rendered• The user navigates between different views• Code in mounted() hook:

Which of the following statements is/are CORRECT about this implementation?

Select all that apply.

  1. A

    If the page is refreshed while the Promise is pending, the token will be lost because localStorage is cleared on refresh

  2. B

    If token validation fails, the token is removed from storage, preventing automatic login on future page loads

  3. C

    The isAuthenticated flag might be false even though a storedToken exists, until the Promise validation completes

  4. D

    sessionStorage should be used instead of localStorage because user tokens should not persist across browser sessions

  5. E

    If the user navigates to a different route while validation is pending, the Promise will still complete and update the user data

Show answer

Correct answers

  • B

    If token validation fails, the token is removed from storage, preventing automatic login on future page loads

  • C

    The isAuthenticated flag might be false even though a storedToken exists, until the Promise validation completes

  • E

    If the user navigates to a different route while validation is pending, the Promise will still complete and update the user data

Question 14 of 15 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 12 Apr 2026, in the January 2026 term (Modern Application Development Ii 06 Apr 26). It carries 3 marks.

More questions from this paper

  1. Q1You are building a login feature for a web application. The frontend sends the user’s email and password to the backend…
  2. Q2Consider the following Vue.js code. What will be printed on the console first?
  3. Q3Consider the following Vue.js application with two different route scenarios and a component that uses reactive data bi…
  4. Q4Consider the following JavaScript code: What will be printed to the console?
  5. Q5Match the following web dev concept given below: Which of the following options correctly matches Concept / Issue and D…
  6. Q6Consider the following Vuex store setup for a user management system: Suppose the following mutation is committed:store…
  7. Q7In Vue 2 (CDN), which of the following correctly describes the timing of the beforeDestroy and destroyed lifecycle hook…
  8. Q8Consider the following HTML: And JavaScript code: What are the values of id and action respectively?
  9. Q9Which of the following statements best describes a permalink?
  10. Q10Consider the following code snippet running in a browser. What will be the output on the console?
  11. Q11Consider the following code snippet running on a browser. What is the output on the console?
  12. Q12Consider the following markup index.html and JavaScript app.js for a Vue application.\ app.js: index.html: Suppose the …
  13. Q13Consider the following html index.html and JavaScript app.js for a Vue application:\ File : index.html File : app.js Su…
  14. Q15Consider the following HTML index.html and JavaScript app.js for a Vue application:\ File: index.html File: app.js Whic…