Quiz Space

Modern Application Development II · Quiz 2 · 6 Aug 2023 · May 2023 term

Question 12: Consider the below javascript program. Assuming the vari…

Question 12

+4.5 marksOne correct option

Consider the below javascript program.

javascript
async function result (x) {
const y = 6;
return new Promise ((reject, resolve) => {
if (((x * 28) / (7 * x) - 2) == 1)
reject(y ** 2)
console.log("Inside Promise")
resolve(y ** 3)
})
}
result(x).then(
rej => console.log("Promise rejected with the value", rej),
res => console.log("Promise resolved with the value", res)
).then(data => {
console.log("Data received is", data);
return "6"
}).finally(data => {
console.log("Data received is", data);
return "34"
}).then(data => console.log("Data received is", data))

Assuming the variable “x” passed to the “result” function is a whole number between 1 and 99 (including 1 and 99), what will be shown on the console, if the above program is executed?

  1. A

    Promise resolved with the value 36
    Data received is 36
    Data received is 6
    Data received is 34

  2. B

    Inside Promise
    Promise rejected with the value 36
    Data received is undefined
    Data received is undefined
    Data received is 34

  3. C

    Promise rejected with the value 216
    Data received is undefined
    Data received is undefined
    Data received is 34

  4. D

    Inside Promise
    Promise rejected with the value 216
    Data received is undefined
    Data received is undefined
    Data received is 6

Show answer

Correct answer

  • D

    Inside Promise
    Promise rejected with the value 216
    Data received is undefined
    Data received is undefined
    Data received is 6

Question 12 of 16 in the IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 6 Aug 2023, in the May 2023 term (IIT M FOUNDATION AN2 EXAM QPF2 06 Aug 2023). It carries 4.5 marks.

More questions from this paper

  1. Q1Consider the below javascript program. What will be the approximate value of the variable “timeDifference”?
  2. Q2Consider the following Vue application with javascript file “app.js” and markup file “index.html”. app.js: index.html: …
  3. Q3Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: app.js: …
  4. Q4Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: app.js: …
  5. Q5Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html app.js Su…
  6. Q6Consider the below javascript program, and predict the output, if executed.
  7. Q7Which of the following is correct regarding the finally block of Promise?
  8. Q8Which of the following statements is true?
  9. Q9Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: Suppose …
  10. Q10Consider the following Vue application with javascript file “app.js” and markup file “index.html”. index.html: app.js: …
  11. Q11Consider the below javascript program, and predict the output, if executed.
  12. Q13Which of the following statement(s) is/are true regarding javascript?
  13. Q14Figure question
  14. Q15Consider the below Vue class bindings: Code 1: Code 2: Which of the following statement(s) is/are true?
  15. Q16Which of the following statement(s) is/are correct in the context of REST and GraphQL?