Quiz Space

September 2023 term · Modern Application Development II · BSCS2006

MAD 2 End Term: 24 December 2023, Set FDD1 (September 2023 term)

The IIT Madras BS Modern Application Development II (MAD 2) End Term paper sat on 24 Dec 2023, in the September 2023 term, set FDD1: 32 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
32
Marks
100
Duration
180 min
MSQ
11
MCQ
21

Updated

Official paper: IIT M DIPLOMA FN EXAM FDD1 24 Dec 2023 · No negative marking.

Question 1

+2 marksOne or more correct options

Which of the following statements is/are correct.

Select all that apply.

  1. A

    SMTP is a mail delivery protocol.

  2. B

    SMTP is a protocol to retrieve email from an email server.

  3. C

    IMAP is a mail delivery protocol.

  4. D

    IMAP is a protocol to retrieve email from an email server.

Show answer

Correct answers

  • A

    SMTP is a mail delivery protocol.

  • D

    IMAP is a protocol to retrieve email from an email server.

Question 2

+2 marksOne or more correct options

Which of the following is/are correct regarding CDN.

Select all that apply.

  1. A

    CDN is an acronym for Content Delivery Network.

  2. B

    CDN is a group of servers that helps in fast delivery of web contents.

  3. C

    Web content is generally delivered from the closest server to the client in the network.

  4. D

    None of these.

Show answer

Correct answers

  • A

    CDN is an acronym for Content Delivery Network.

  • B

    CDN is a group of servers that helps in fast delivery of web contents.

  • C

    Web content is generally delivered from the closest server to the client in the network.

Question 3

+2 marksOne or more correct options

Which of the following statement(s) is/are false regarding javascript language?

Select all that apply.

  1. A

    Replit.com is an example of a javascript engine.

  2. B

    The language supports the concept of first class functions.

  3. C

    The language does not allow the implementation of user defined higher order functions.

  4. D

    The language can be used for DOM manipulation.

Show answer

Correct answers

  • A

    Replit.com is an example of a javascript engine.

  • C

    The language does not allow the implementation of user defined higher order functions.

Question 4

+2 marksOne or more correct options

Which of the following method(s) can be used to ensure that the displayed state and system state are kept in sync at all times?

Select all that apply.

  1. A

    Ajax requests on each UI change

  2. B

    Periodic reloading of web-page

  3. C

    Vue bindings to update data reactively

  4. D

    Pure static pages with all updates rendered from server

Show answer

Correct answers

  • A

    Ajax requests on each UI change

  • D

    Pure static pages with all updates rendered from server

Question 5

+2 marksOne or more correct options

Select all that apply.

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

Correct answers

  • B
  • D

Question 6

+2 marksOne or more correct options

Which of the following statement(s) is/are true regarding webhooks?

Select all that apply.

  1. A

    A webhook uses HTTP protocol.

  2. B

    A webhook uses web socket protocol.

  3. C

    A webhook receiver must be deployed on the same origin as the webhook initiator.

  4. D

    A webhook is supposed to be used for machine to machine communication.

Show answer

Correct answers

  • A

    A webhook uses HTTP protocol.

  • D

    A webhook is supposed to be used for machine to machine communication.

Question 7

+3 marksOne or more correct options

Which of the following is correct regarding XSS attacks?

Select all that apply.

  1. A

    XSS attack is an exploit where an attacker attaches a malicious code into a website.

  2. B

    XSS can be used to steal the user's cookie.

  3. C

    XSS is a client side injection attack.

  4. D

    It can be avoided by validating the user's input.

Show answer

Correct answers

  • A

    XSS attack is an exploit where an attacker attaches a malicious code into a website.

  • B

    XSS can be used to steal the user's cookie.

  • C

    XSS is a client side injection attack.

  • D

    It can be avoided by validating the user's input.

Question 8

+3 marksOne or more correct options

You are trying to build a distributed system with N servers, each of which may need to communicate with any of the other servers. Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    With point-to-point communication, the number of connection links will grow as O(n).

  2. B

    With point-to-point communication, the number of connection links will grow as O(n²).

  3. C

    With the use of a central message broker, the number of connection links will grow as O(n).

  4. D

    With the use of a central message broker, the number of connection links will grow as O(n²).

Show answer

Correct answers

  • B

    With point-to-point communication, the number of connection links will grow as O(n²).

  • C

    With the use of a central message broker, the number of connection links will grow as O(n).

Question 9

+3 marksOne or more correct options

Which of the following statement(s) is/are false regarding long and short polling?

Select all that apply.

  1. A

    A webhook is the same as short polling.

  2. B

    The short polling can be used to know the state of an asynchronous task, and trigger an action if the task gets completed.

  3. C

    The long polling cannot be achieved using HTTP protocol.

  4. D

    Long Polling can be used to achieve real time communication.

Show answer

Correct answers

  • A

    A webhook is the same as short polling.

  • C

    The long polling cannot be achieved using HTTP protocol.

Question 10

+3 marksOne or more correct options

Which of the following statement(s) is/are true regarding caching?

Select all that apply.

  1. A

    It is recommended to cache the social networking apps feed responses for a longer duration.

  2. B

    Caching is primarily done to reduce the load from the origin server.

  3. C

    The shared cache is meant to serve responses to the multiple users.

  4. D

    A browser cannot cache JavaScript corresponding to a web page.

Show answer

Correct answers

  • B

    Caching is primarily done to reduce the load from the origin server.

  • C

    The shared cache is meant to serve responses to the multiple users.

Question 11

+3 marksOne or more correct options

Which of the following statements is true regarding CORS and CSRF?

Select all that apply.

  1. A

    CORS stands for Cross Origin Resource Sharing.

  2. B

    The CORS reduces chances of malicious code by explicitly saying which URLs can be originators of data.

  3. C

    CSRF stands for Cross Site Request Forgery.

  4. D

    None of these.

Show answer

Correct answers

  • A

    CORS stands for Cross Origin Resource Sharing.

  • B

    The CORS reduces chances of malicious code by explicitly saying which URLs can be originators of data.

  • C

    CSRF stands for Cross Site Request Forgery.

Question 12

+4.5 marksOne correct option

Consider the following JavaScript code.

javascript
function goUpDown(num) {
return new Promise((res, rej) => {
setTimeout(() => {
if (num < 20) {
return num > 10 ? res('Go Up') : res('Go Down')
} else {
return rej('Number Too Large')
}
}, 1000)
})
}
async function getData() {
const data3 = await goUpDown(8)
const data2 = await goUpDown(15)
const data1 = await goUpDown(30)
}
getData().then(
(data) => {
console.log(data)
},
(err) => {
console.log(err)
}
)

What will be logged on to console, if executed?

  1. A

    Go Up

  2. B

    Go Down

  3. C

    Number Too Large

  4. D

    None of these

Show answer

Correct answer

  • C

    Number Too Large

Question 13

+4.5 marksOne correct option

Consider the following JavaScript code.

javascript
class Tshirt {
constructor(size, price) {
this.size = size
this.price = price
}
}
class LargeTshirt extends Tshirt {
constructor() {
super('large', 500)
}
}
class MediumTshirt extends Tshirt {
constructor() {
super('medium')
}
}
class Order {
constructor(item, count) {
this.item = item
this.count = count
}
totalPrice() {
try {
return this.item.price * this.count
} catch {
return 'Some Error'
}
}
}
const t1 = new LargeTshirt()
const order = new Order(t1, 5)
console.log(order.totalPrice())

What will be logged on to console, if executed?

  1. A

    NaN

  2. B

    500

  3. C

    2500

  4. D

    Some Error

Show answer

Correct answer

  • C

    2500

Question 14

+4.5 marksOne correct option

Consider the following Vue application with JavaScript “app.js” and markup “index.html”

app.js

javascript
new Vue({
el: '#app',
template: `<div>
<div v-for="item in items">
Name:{{item.name}},Count:{{item.count}}, Price:
{{item.price*item.count}}
<button @click="inscreeseCount(item)">Increese Count</button>
<button @click="addToCart(item)">Add To Cart</button>
</div>
Total Amount: {{amount}} <button @click="buy"> Buy </button>
</div>`,
data: {
cart: [],
totalAmount: 50,
items: [
{ name: 'Apple', count: 1, price: 10 },
{ name: 'Orange', count: 1, price: 5 },
],
},
methods: {
buy() {
if (this.amount > this.totalAmount) {
console.log('Failure')
} else {
console.log('Success')
this.cart = []
}
},
inscreeseCount(item) {
item.count += 2
},
addToCart(item) {
this.cart.push(item)
},
},
computed: {
amount() {
let total = 0
this.cart.forEach((item) => {
total += item.count * item.price
})
return total
},
},
})

index.html

html
<body>
<div id="app"></div>
</body>

Suppose the application is running on “http://127.0.0.1:8080/”. Suppose the user clicks on “Increese count” button associated with the item name “Apple” 10 times and then clicks on the button “Buy”. What will be logged on to console?

  1. A

    Success

  2. B

    Failure

  3. C

    NaN

  4. D

    None of these

Show answer

Correct answer

  • A

    Success

Question 15

+4.5 marksOne correct option

Consider the following Vue app with markup “index.html” and JavaScript “app.js”

app.js

javascript
const Error = {
template: `<div>Result Not Found</div>`,
}
const Dashboard = {
template: `<div> This is dashboard of {{user}}</div>`,
props: ['user'],
}
const routes = [
{ path: '/dashboard/:user', component: Dashboard, props: true },
{ path: '*', component: Error },
]
const router = new VueRouter({
routes,
})
new Vue({
el: `#app`,
template: `<router-view />`,
router,
})

index.html

html
<body>
<div id="app"></div>
</body>

Suppose the application is running on “http://127.0.0.1:8080/”. What will be rendered by the browser for “http://127.0.0.1:8080/#/”?

  1. A

    This is dashboard of User

  2. B

    Dashboard

  3. C

    Error

  4. D

    Result Not Found

Show answer

Correct answer

  • D

    Result Not Found

Question 16

+4.5 marksOne correct option

Consider the following flask application.

app.py

python
from flask import Flask
from flask_caching import Cache
from time import sleep
config = {
"CACHE_TYPE": "RedisCache",
"CACHE_REDIS_HOST": "localhost",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1
}
app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)
@app.get('/')
@cache.cached(timeout=120)
def home():
sleep(30)
return "hello world"
if __name__ == "__main__":
app.run(debug=True)

Suppose the application is running on “http://localhost:5000”. If user1 visits the URL “http://localhost:5000” and after 50 seconds user2 visits the same URL. What will be the approx difference between the response time for user1 and user2?

  1. A

    0 seconds

  2. B

    30 seconds

  3. C

    120 seconds

  4. D

    None of these

Show answer

Correct answer

  • B

    30 seconds

Question 17

+4.5 marksOne correct option

Consider the below javascript program.

javascript
exams = ['Jan 2023', 'May 2023', 'Sep 2023']
new Promise((rej, res) => {
let count = 2
let a = setInterval(() => {
count += 3;
const last = exams.pop();
if (count % 2) {
exams.push('May 2023')
}
else if (count % 5 == 0) {
clearInterval(a);
rej(last);
}
}, 2000)
}).then(d => console.log("Resolved", exams, d)
).catch(e => console.log("Rejected", exams, d))

What will be the output of the above program, if executed? Also, predict the minimum number of seconds the program will take to complete the execution?

  1. A

    Resolved []
    Minimum Time Taken: 12 seconds

  2. B

    Resolved [] May 2023
    Minimum Time Taken: 10 seconds

  3. C

    Rejected [May 2023] May 2023
    Minimum Time Taken: 12 seconds

  4. D

    Rejected [May 2023]
    Minimum Time Taken: 10 seconds

  5. E

    Resolved [] May 2023
    Minimum Time Taken: 12 seconds

  6. F

    Rejected [] May 2023
    Minimum Time Taken: 10 seconds

Show answer

Correct answer

  • E

    Resolved [] May 2023
    Minimum Time Taken: 12 seconds

Question 18

+4.5 marksOne correct option

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

index.html:

html
<div id = "app">
<input v-model = "name" @input = "do_something">
<p> {{age}} </p>
</div>
<script scr = "app.js"></script>

app.js:

javascript
new Vue({
el : "#app",
data : {
name : "#app",
age : 0,
},
mounted () {
try {
this.name = localStorage.getItem("name").split(" ")[0];
this.age = localStorage.getItem("name").split(" ")[1];
localStorage.setItem("name",
localStorage.getItem("name").split(" ")[0] + " " + this.name);
}
catch {
this.name = "Default";
this.age = "Default";
}
},
methods : {
do_something() {
localStorage.setItem("name", this.name);
localStorage.setItem("age", this.age);
}
}
})

Suppose you open “index.html” file in a browser, and type the text “IIT Madras” in the text box shown (after removing the previous text, if any), and hard refresh the page twice, without clicking anywhere. What will be the value shown in the text box, and the “age” placeholder, respectively?

  1. A

    The app will show an error in the console

  2. B

    Default, Default

  3. C

    IIT, Madras

  4. D

    IIT, IIT

  5. E

    Madras, IIT

  6. F

    None of these

Show answer

Correct answer

  • D

    IIT, IIT

Question 19

+4.5 marksOne correct option

Fill in code1 & code2, which can be used in Vuex Store to update the “below_average” state variable with the objects of those students who have scored more than 50 marks.

javascript
const store= new Vuex.Store({
state:{
student_total:0,
students:[
{
name : 'Akshay',
marks : 52
},
{
name : 'Vishwajeet',
marks : 78
},
{
name : 'Sonali',
marks : 43
}
],
below_average:[]
},
code1:{
belowAverageStudents(state){
code2
},
}
})
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 20

+3 marksOne correct option

Consider the following JavaScript code.

javascript
async function getResponse(url) {
try {
const response = await fetch(url)
try {
const data = await response.json()
if (response.ok) {
return data
} else {
return response.status
}
} catch {
return 'Network Error'
}
} catch {
return 'Response is not json'
}
}
getResponse('url').then((data) => {
console.log(data)
})

Suppose ‘url’ returns an HTML response for a get request with 200 status code. What will be logged on to console, if the code is executed?

  1. A

    Response is not json

  2. B

    Network Error

  3. C

    200

  4. D

    None of these

Show answer

Correct answer

  • B

    Network Error

Question 21

+3 marksOne correct option

Consider the JavaScript code. Suppose the ‘url’ returns a JSON response with 404 status code. What will be logged on to console?

javascript
async function getResponse(url) {
try {
const response = await fetch(url)
try {
const data = await response.json()
if (response.ok) {
return data
} else {
return response.status
}
} catch {
return 'Network Error'
}
} catch {
return 'Response is not json'
}
}
getResponse('url').then((data) => {
console.log(data)
})
  1. A

    Response is not json

  2. B

    Network Error

  3. C

    404

  4. D

    None of these

Show answer

Correct answer

  • C

    404

Question 22

+3 marksOne correct option

Consider the following JavaScript code.

javascript
class Tshirt {
constructor(size, price) {
this.size = size
this.price = price
}
}
class LargeTshirt extends Tshirt {
constructor() {
super('large', 500)
}
}
class MediumTshirt extends Tshirt {
constructor() {
super('medium')
}
}
class Order {
constructor(item, count) {
this.item = item
this.count = count
}
totalPrice() {
try {
return this.item.price * this.count
} catch {
return 'Some Error'
}
}
}
const t1 = new MediumTshirt()
const order = new Order(t1, 5)
console.log(order.totalPrice())

What will be logged on to console, if executed?

  1. A

    NaN

  2. B

    500

  3. C

    2500

  4. D

    Some Error

Show answer

Correct answer

  • A

    NaN

Question 23

+3 marksOne correct option

app.js

javascript
new Vue({
el: '#app',
template: `<div>
<div v-for="item in items">
Name:{{item.name}},Count:{{item.count}}, Price:
{{item.price*item.count}}
<button @click="inscreeseCount(item)">Increese Count</button>
<button @click="addToCart(item)">Add To Cart</button>
</div>
Total Amount: {{amount}} <button @click="buy"> Buy </button>
</div>`,
data: {
cart: [],
totalAmount: 50,
items: [
{ name: 'Apple', count: 1, price: 10 },
{ name: 'Orange', count: 1, price: 5 },
],
},
methods: {
buy() {
if (this.amount > this.totalAmount) {
console.log('Failure')
} else {
console.log('Success')
this.cart = []
}
},
inscreeseCount(item) {
item.count += 2
},
addToCart(item) {
this.cart.push(item)
},
},
computed: {
amount() {
let total = 0
this.cart.forEach((item) => {
total += item.count * item.price
})
return total
},
},
})
  1. A

    Success

  2. B

    Failure

  3. C

    NaN

  4. D

    None of these

Show answer

Correct answer

  • B

    Failure

Question 24

+3 marksOne correct option

app.js

javascript
const Error = {
template: `<div>Result Not Found</div>`,
}
const Dashboard = {
template: `<div> This is dashboard of {{user}}</div>`,
props: ['user'],
}
const routes = [
{ path: '/dashboard/:user', component: Dashboard, props: true },
{ path: '*', component: Error },
]
const router = new VueRouter({
routes,
})
new Vue({
el: `#app`,
template: `<router-view />`,
router,
})

index.html

html
<body>
<div id="app"></div>
</body>
  1. A

    This is dashboard of User

  2. B

    This is dashboard of 2

  3. C

    Dashboard

  4. D

    Result Not Found

Show answer

Correct answer

  • B

    This is dashboard of 2

Question 25

+3 marksOne correct option

app.py

python
from flask import Flask
from flask_caching import Cache
from time import sleep
config = {
"CACHE_TYPE": "RedisCache",
"CACHE_REDIS_HOST": "localhost",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1
}
app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)
@app.get('/')
@cache.cached(timeout=120)
def home():
sleep(30)
return "hello world"
if __name__ == "__main__":
app.run(debug=True)
  1. A

    0 seconds

  2. B

    30 seconds

  3. C

    120 seconds

  4. D

    None of these

Show answer

Correct answer

  • A

    0 seconds

Question 26

+3 marksOne correct option

Consider the below javascript program.

javascript
var first = 1;
obj1 = {
'first' : 2,
'second' : function some () {
console.log(this.first);
}
}
obj2 = {
'first' : 3,
'second' : () => {
console.log("Function Invoked !!");
this.second();
}
}
obj2.second.call(obj1);

What will be the output of the above program, if executed?

  1. A

    Function Invoked !!
    2

  2. B

    Function Invoked !!
    3

  3. C

    Function Invoked !!
    1

  4. D

    Function Invoked !!
    Error

  5. E

    Error

Show answer

Correct answer

  • D

    Function Invoked !!
    Error

Question 27

+3 marksOne correct option

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

index.html:

html
<div id = "app">
<my-comp>
<template v-slot:first = "slotProps">
This is from {{slotProps.user.name1}} template
</template>
<template v-slot:default = "slotProps">
This is from {{slotProps.user.name3}} template
</template>
<template v-slot:second = "slotProps">
This is from {{slotProps.user.name2}} template
</template>
</my-comp>
</div>
<script src = "app.js"> </script>

app.js:

javascript
Vue.component("myComp", {
template : `<div>
<p>
<slot name = "first" v-bind:user="user">
</slot>
</p>
<p>
<slot v-bind:user="user">
</slot>
</p>
</div>
`,
data : function () {
return {
user : {
'name1' : "Rashmi's",
'name2' : "Akshay's",
'name3' : "Sumit's",
}
}
}
})
const app = new Vue({
el : "#app",
})
  1. A

    This is from template
    This is from template

  2. B

    This is from Rashmi’s template
    This is from Akshay’s template
    This is from Sumit’s template

  3. C

    This is from Rashmi’s template
    This is from Sumit’s template

  4. D

    This is from Rashmi’s template
    This is from Sumit’s template
    This is from Akshay’s template

  5. E

    This is from template
    This is from template
    This is from template

Show answer

Correct answer

  • C

    This is from Rashmi’s template
    This is from Sumit’s template

Question 28

+3 marksOne correct option

Consider the below javascript program.

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

Correct answer

  • C

Question 29

+3 marksOne correct option

Suppose an attacker embeds a malicious link in an email or website, causing the victim's browser to unknowingly submit a form that performs an action (e.g., deleting the user’s account) on the target site where the victim is authenticated. Which type of attack is this?

  1. A

    Denial Of Service Attack

  2. B

    CSRF Attack

  3. C

    Flooding Attack

  4. D

    None of these

Show answer

Correct answer

  • B

    CSRF Attack

Question 30

+3 marksOne correct option

Consider the below javascript program.

javascript
async function func() {
const num = await Promise.resolve(2);
console.log("Second");
return num;
}
console.log("First");
func().then((data) => console.log(data));
console.log("Third");

What will be the output of the above program, if executed?

  1. A

    First
    Second
    Third
    2

  2. B

    First
    Error

  3. C

    First
    Third
    Second
    undefined

  4. D

    First
    Third
    Second
    2

  5. E

    The output cannot be predicted

Show answer

Correct answer

  • D

    First
    Third
    Second
    2

Question 31

+2 marksOne correct option

Which of the following is/are valid use(s) of “v-for” directive, assuming “obj” is an object having a number of key value pairs?

  1. A

    v-for = “value in obj”

  2. B

    v-for = “(value, name) in obj”

  3. C

    v-for = “(value, name, index) in obj”

  4. D

    All of these.

Show answer

Correct answer

  • D

    All of these.

Question 32

+2 marksOne correct option

Which of the following statement(s) is/are true regarding Celery?

  1. A

    A celery system may consist of multiple brokers.

  2. B

    Redis must be used as a message broker for Celery.

  3. C

    The framework does not support periodic scheduling of tasks.

  4. D

    All of these.

Show answer

Correct answer

  • A

    A celery system may consist of multiple brokers.