
Modern Application Development II Quiz 1: 7 July 2024 (May 2024 term)
The IIT Madras BS Modern Application Development II (MAD 2) Quiz 1 paper sat on 7 Jul 2024, in the May 2024 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
- 16
- 50
- 120 min
- 15
- 1
Show answer
Correct answer
Question 2
What will be the output of the following code snippet?
let result = "";for (let i = 0; i < 3; i++) { for (let j = 0; j < 2; j++) { result += " " + i + j + " "; }}console.log(result);Show answer
Correct answer
Question 3
Which of the following statements best describes the ephemeral state?
Data that persists across browser sessions.
Data that is stored in a server-side database.
Temporary data that is not preserved across re-renders.
Data that is cached in the client's browser.
Show answer
Correct answer
Temporary data that is not preserved across re-renders.
Question 4
What is the difference between v-bind and v-model directives in Vue.js?
“v-bind” is used for one-way data binding, while “v-model” is used for two-way data binding.
“v-bind” is used for two-way data binding, while “v-model” is used for one-way data binding.
Both “v-bind” and “v-model” are used for one-way data binding.
Both “v-bind” and “v-model” are used for two-way data binding.
Show answer
Correct answer
“v-bind” is used for one-way data binding, while “v-model” is used for two-way data binding.
Question 5
Show answer
Correct answer
Question 6
Consider the below JavaScript program.
const a = 15;
const obj1 = { a: 20, b: function () { console.log(this.a); this.b(); }}
const obj2 = { a: 10, b: () => { console.log(this.a); }}
obj1.b.apply(obj2);What will be the output of the above program, if executed?
Show answer
Correct answer
Question 7
Consider the below JavaScript program.
let users = [ { name: "Alice", age: 25 }, { name: "Bob", age: 22 }, { name: "Charlie", age: 30 },];users.sort((a, b) => a.age - b.age);console.log(users.map((user) => user.name).join(", "));What will be the output when the code is executed?
Show answer
Correct answer
Question 8
Show answer
Correct answer
Question 9
What is state management in the context of a web application?
Organizing and storing data on the server-side database.
Handling and updating the state of client-side components and data.
Managing user session data using browser cookies.
Coordinating the state of HTTP requests and responses between client and server.
Show answer
Correct answer
Handling and updating the state of client-side components and data.
Question 10
Consider the following JavaScript program.
const obj1={ age: 29, toy: 'kite'}
const obj2={ __proto__: obj1, animal: 'dogs', members: 45}
console.log(obj1.toy)console.log(obj1.animal)console.log(obj2.age)console.log(obj2.members)console.log(Object.keys(obj2))What will be the output of the above program, if executed?
Show answer
Correct answer
Question 11
Consider the following html.
<div id="app"> <p>{{ message }}</p> <button @click="updateMessage">Click me</button></div>
<script>new Vue({ el: '#app', data: { message: 'Hello!' }, methods: { updateMessage() { this.message += '!'; } }});</script>Assuming vue cdn has been added to the html and the html format is correct. What would be the output on the screen after clicking the button twice?
Show answer
Correct answer
Question 12
Which of the following is/are correct definition(s) of an arrow function that accepts a number and returns its square?
Show answer
Correct answers
Question 13
Consider the following JavaScript code embedded in the body of the HTML document given below.
<html><body> <div id="mybox">Test JS</div> <script> let count = 0; let change = setInterval(()=>{ let box = document.getElementById('mybox'); if(count % 2 == 1){ box.style.backgroundColor = 'red'; count++; } else if(count % 3 == 1){ box.style.backgroundColor = 'green'; count++ } else{ box.style.backgroundColor = 'yellow'; count++ } }, 1000) </script></body></html>If the document is rendered on the browser, what will be the sequence of background colors taken by the element with id="mybox" in the first 6 seconds of execution?
Show answer
Correct answer
Question 14
Consider the below JavaScript program.
class Region{ constructor(region){ this.region = region; } get describe(){ return `${this.region} is one of the major geographical regions.` }}
class Country extends Region { constructor(region, country, nation){ super(region) this.country = country; this.nation = nation; }
get describe(){ return `${this.country} is a ${this.nation} nation in the region of${this.region}.` }}
let Australia = new Region('Australia and NZ', 'Australia', 'developed')let Germany = new Country('Europe', 'Germany', 'developed')console.log(Australia.describe)console.log(Germany.describe)What will be the output of the above program, if executed?
Show answer
Correct answer
Question 15
Consider the following Vue application with markup index.html and JavaScript file app.js.
File: index.html
<div id = "app"> <div>Welcome to Frontend Development</div> <new>Vue is a Frontend Framework</new></div><script src="script.js"></script>File: script.js
Vue.component('new', { template : `<div> <slot>Vue is JS Framework</slot> <div>Learn Vue 2 and Vue 3</div> </div> `
});
new Vue({ el : "#app",})What will be rendered on the browser screen?
Show answer
Correct answer
Question 16
Consider the following html.
<div id="app"> <parent-component :title="parentTitle"> <template slot="header"> <h2>{{ headerTitle }}</h2> </template> </parent-component></div>
<script>Vue.component('parent-component', { props: ['title'], template: ` <div> <h1>{{ title }}</h1> <slot name="header"></slot> <p>Main Content</p> </div> `});
new Vue({ el: '#app', data: { parentTitle: 'Parent Component Title', headerTitle: 'Header Content' }});</script>Assuming Vue CDN has been added to the HTML and the HTML format is correct. What would be the output on the screen?
Show answer
Correct answer