Quiz Space

Modern Application Development II Quiz 2: 10 July 2022 (May 2022 term)

Question 1

+3 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”. index.html:

app.js:

javascript
const a = new Vue({
el : '#app',
data : {
data : "",
refreshes : 0,
},
methods: {
do_something() {
if (isNaN(this.refreshes)) this.refreshes = 0;
if (this.data.length % 2) {
sessionStorage.data = "prefix" + this.data;
sessionStorage.refreshes = this.refreshes * 2 + 1;
}
else {
javascript
sessionStorage.data = this.data + "suffix";
sessionStorage.refreshes = this.refreshes * 2 - 1;
}
}
},
mounted : function () {
if (sessionStorage.data) {
this.data = "suffix" + sessionStorage.data;
this.refreshes = Number(sessionStorage.refreshes) % 3 - 1;
}
else {
this.data = sessionStorage.data + "prefix";
this.refreshes = Number(sessionStorage.refreshes) % 3 + 1;
}
sessionStorage.data = this.data;
sessionStorage.refreshes = this.refreshes;
}
})

Say you open the file “index.html” in the browser, and enter the text “iitm” in the text box shown (after removing the existing text from the input box), and click on the button with the text “Click Me”. After that, you refresh the page twice. What will be the text shown in the text input box, and the value of the “refreshes” placeholder, respectively?

  1. A

    suffixiitmsuffix, -2

  2. B

    suffixsuffixiitmsuffix, -2

  3. C

    suffixsuffixiitmsuffix, -3

  4. D

    suffixiitmsuffix, -3

Question 2

+3 marksOne correct option

Suppose you are organizing a ceremony to award the startup companies who have progressed considerably well in the past few years. You have received a lot of registrations. The committee has decided to shortlist the companies based on the following 2 criteria:
1. The company must have a website
2. The company must have a capital of more than 40000
Fill in the code1 & code2, which can be used in Vuex Store to update the “awardees” state variable with the objects of those companies who satisfy the above-mentioned criteria.

javascript
const store = new Vuex.Store({
state : {
companies : [
{
name : 'sample1',
website : 'sample1.com',
capital : 50000
},
{
name : 'sample2',
website : null,
capital : 75000
},
{
name : 'sample3',
website : 'sample3.com',
capital : 42000
},
{
name : 'sample4',
website : 'sample4.com',
capital : 38000
},
],
awardees : []
},
mutations : {
update_final(state, minimum) {
for (company of state.companies)
code2
}
},
actions : {
send_task : function (context) {
code1
}
}
})
  1. A
  2. B
  3. C
  4. D

Question 3

+3 marksOne correct option

Consider the following JavaScript program running in a browser environment.

javascript
async function FetchFunct(ApiUrl) {
const response = await fetch(ApiUrl).catch(() => {
throw new Error('Network Error')
})
if (response) {
if (response.ok) {
const data = await response.json().catch(() => {
throw new Error('Unexpected Error')
})
if (data) {
return data
}
} else {
throw new Error(response.statusText)
}
}
}
Const url = ‘dummyUrl’
FetchFunct(url)
.then((data) => {
console.log(data)
})
.catch((err) => {
console.log(err.message)
})

Consider the ‘dummyUrl’ returns the HTML as payload. What will be logged on to the console?

  1. A

    Network Error

  2. B

    Unexpected Error

  3. C

    Not Found

  4. D

    None of these

13 more questions in this paper

Sign in with Google — it is free — to see every question with its answer and explanation, practise it in learning mode, or take it as a timed mock test.

More on the MAD 2 Quiz 2 10 Jul 2022 paper

The IIT Madras BS Modern Application Development II (MAD 2) Quiz 2 paper sat on 10 Jul 2022, in the May 2022 term: 16 questions for 50 marks in 120 minutes. The first 3 questions are below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureMAD 2 Quiz 2 10 Jul 2022 at a glance
TermMay 2022 term
SubjectModern Application Development II
Course codeBSCS2006
Questions16
Marks50
Duration120 min
MCQ10
MSQ6
Official paperIIT M DIPLOMA QUIZ2 EXAM QPE1 10 July 2022
Negative markingNo negative marking.
Updated

Same Quiz 2, other subjects

More MAD 2