Quiz Space

Modern Application Development II · Quiz 2 · 3 Aug 2025 · May 2025 term

Question 8: Consider the following JavaScript program: What will be t…

Question 8

+3 marksOne correct option

Consider the following JavaScript program:

javascript
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('The cat sleeps');
}, 2000);
});
promise1
.then((result) => {
console.log(result);
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Rain falls gently');
}, 1000);
});
})
.then((result) => {
console.log(result);
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Books gather dust');
}, 1500);
});
})
.then((result) => {
console.log(result);
throw new Error('Coffee grows cold');
})
.then((result) => {
console.log('Stars shine bright');
})
.catch((error) => {
console.log("Caught:", error.message);
});

What will be the output of the above program when executed?

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answer

  • B

Question 8 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 3 Aug 2025, in the May 2025 term (IIT M DIPLOMA AN EXAM QDD2 03 Aug 2025). It carries 3 marks.

More questions from this paper

  1. Q1Suppose a client wants to make a POST request using the Fetch API to a public endpoint at /api/submit, which includes s…
  2. Q2Which of the following statements are true?
  3. Q3Which of the following statement(s) about Web Storage APIs is/are correct?
  4. Q4Which of the following statement(s) is/are true regarding Single Page Applications (SPA) and Progressive Web Apps (PWA)?
  5. Q5Consider the following code snippet. What will be logged to the console?
  6. Q6The following code is using Vue 2 and Vue router 3 running on http://127.0.0.1:5500. Filename: index.html Filename: rou…
  7. Q7Consider the following Vue 2 component defined using the CDN version: Filename: index.html Filename: app.js What will b…
  8. Q9Consider the following Vue application with markup "index.html" and JavaScript file "app.js". Filename: index.html File…
  9. Q10Consider the following Vue 2 code with Vuex 3 used via CDN, assume the Vuex store is correctly injected into the Vue in…
  10. Q11Filename: app.js Suppose the application is running on "http://localhost:3000", select the correct option(s)?
  11. Q12The following code is using Vue 2 and Vue router 3 running on http://127.0.0.1:5500. Filename: index.html Filename: rou…
  12. Q13Consider the following Vue application with markup "index.html" and JavaScript file "app.js". Filename: index.html File…
  13. Q14Consider the following Vuex store setup for a user management system: What will happen when the following sequence of o…
  14. Q15You are given the following HTML and JavaScript code that uses Vue 2 via CDN along with Vue Router. Read the code caref…
  15. Q16Suppose the button is clicked multiple times quickly, the message area flickers unexpectedly. How can you improve the c…