MAD Study Hub

Home / Past papers / MAD2 End Term / this paper

2023 Dec24: IIT M FN EXAM FDD2 - 24 Dec 2023

MAD2 End Term32 questions100 marks21 MCQ · 11 MSQforenoon
Elapsed 00:00
Q1MSQ2 marksselect all that apply
Which of the following statements is/are correct.
  1. SMTP is a mail delivery protocol.
  2. SMTP is a protocol to retrieve email from an email server.
  3. IMAP is a mail delivery protocol.
  4. IMAP is a protocol to retrieve email from an email server.
Q2MSQ2 marksselect all that apply
Which of the following is/are correct regarding CDN.
  1. CDN is an acronym for Content Delivery Network.
  2. CDN is a group of servers that helps in fast delivery of web contents.
  3. Web content is generally delivered from the closest server to the client in thenetwork.
  4. None of these.
Q3MSQ2 marksselect all that apply
Which of the following statement(s) is/are false regarding javascript language?
  1. Replit.com is an example of a javascript engine.
  2. The language supports the concept of first class functions.
  3. The language does not allow the implementation of user defined higher orderfunctions.
  4. The language can be used for DOM manipulation.
Q4MSQ2 marksselect all that apply
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?
  1. Ajax requests on each UI change
  2. Periodic reloading of web-page
  3. Vue bindings to update data reactively
  4. Pure static pages with all updates rendered from server
Q5MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Suppose an application is loaded from an origin "https://xyz.com". Which of the following origins will result in a CORS error, while making a fetch call, by default?
  1. question figure
    text
    https://xyz.com
  2. question figure
    text
    https://abc.xyz.com
  3. question figure
    text
    https://xyz.com/page1
  4. question figure
    text
    https://xyz6.com
Q6MSQ2 marksselect all that apply
Which of the following statement(s) is/are true regarding webhooks?
  1. A webhook uses HTTP protocol.
  2. A webhook uses web socket protocol.
  3. A webhook receiver must be deployed on the same origin as the webhookinitiator.
  4. A webhook is supposed to be used for machine to machine communication.
Q7MSQ3 marksselect all that apply
Which of the following is correct regarding XSS attacks?
  1. XSS attack is an exploit where an attacker attaches a malicious code into awebsite.
  2. XSS can be used to steal the user's cookie.
  3. XSS is a client side injection attack.
  4. It can be avoided by validating the user's input.
Q8MSQ3 marksselect all that apply
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?
  1. With point-to-point communication, the number of connection links will growas O(n).
  2. With point-to-point communication, the number of connection links will growas O(n2).
  3. With the use of a central message broker, the number of connection links willgrow as O(n).
  4. With the use of a central message broker, the number of connection links willgrow as O(n2).
Q9MSQ3 marksselect all that apply
Which of the following statement(s) is/are false regarding long and short polling?
  1. A webhook is the same as short polling.
  2. The short polling can be used to know the state of an asynchronous task, andtrigger an action if the task gets completed.
  3. The long polling cannot be achieved using HTTP protocol.
  4. Long Polling can be used to achieve real time communication.
Q10MSQ3 marksselect all that apply
Which of the following statement(s) is/are true regarding caching?
  1. It is recommended to cache the social networking apps feed responses for alonger duration.
  2. Caching is primarily done to reduce the load from the origin server.
  3. The shared cache is meant to serve responses to the multiple users.
  4. A browser cannot cache JavaScript corresponding to a web page.
Q11MSQ3 marksselect all that apply
Which of the following statements is true regarding CORS and CSRF?
  1. CORS stands for Cross Origin Resource Sharing.
  2. The CORS reduces chances of malicious code by explicitly saying which URLscan be originators of data.
  3. CSRF stands for Cross Site Request Forgery.
  4. None of these.
Q12MCQ4.5 marks
Consider the following JavaScript code. question figure Consider the following JavaScript code. What will be logged on to console, if executed?
Text of the picture (copyable)
```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)
  }
)
```
  1. Go Up
  2. Go Down
  3. Number Too Large
  4. None of these
Q13MCQ4.5 marks
Consider the following JavaScript code. question figure Consider the following JavaScript code. What will be logged on to console, if executed?
Text of the picture (copyable)
```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())
```
  1. NaN
  2. 500
  3. 2500
  4. Some Error
Q14MCQ4.5 marks
Consider the following Vue application with JavaScript “app.js” and markup “index.html” question figure Consider the following Vue application with JavaScript “app.js” and markup “index.html” question figure Consider the following Vue application with JavaScript “app.js” and markup “index.html”
Text of the picture (copyable)
```javascript
app.js
new Vue({
  el: '#app',
  template: `
    <div v-for="item in items">
      Name:{{item.name}}, Count:{{item.count}}, Price:
      {{item.price*item.count}}
      <button @click="inscreeseCount(item)">Increase Count</button>
      <button @click="addToCart(item)">Add To Cart</button>
    </div>
    Total Amount: {{amount}} <button @click="buy"> Buy </button>
  `,
  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 "Increase 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. Success
  2. Failure
  3. NaN
  4. None of these
Q15MCQ4.5 marks
Consider the following Vue app with markup “index.html” and JavaScript “app.js” question figure Consider the following Vue app with markup “index.html” and JavaScript “app.js”
Text of the picture (copyable)
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. This is dashboard of User
  2. Dashboard
  3. Error
  4. Result Not Found
Q16MCQ4.5 marks
Consider the following flask application. question figure Consider the following flask application.
Text of the picture (copyable)
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. 0 seconds
  2. 30 seconds
  3. 120 seconds
  4. None of these
Q17MCQ4.5 marks
Consider the below javascript program. question figure Consider the below javascript program.
Text of the picture (copyable)
```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. Resolved []Minimum Time Taken: 12 seconds
  2. Resolved [] May 2023Minimum Time Taken: 10 seconds
  3. Rejected [May 2023] May 2023Minimum Time Taken: 12 seconds
  4. Rejected [May 2023]Minimum Time Taken: 10 seconds
  5. Resolved [] May 2023Minimum Time Taken: 12 seconds
  6. Rejected [] May 2023Minimum Time Taken: 10 seconds
Q18MCQ4.5 marks
Consider the following Vue application with markup “index.html” and javascript file “app.js”. question figure Consider the following Vue application with markup “index.html” and javascript file “app.js”. 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?
Text of the picture (copyable)
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);
        }
    }
})
```
  1. The app will show an error in the console
  2. Default, Default
  3. IIT, Madras
  4. IIT, IIT
  5. Madras, IIT
  6. None of these
Q19MCQ4.5 marks
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. question figure 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.
Text of the picture (copyable)
```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. question figure
    text
    ```
    code1: mutations
    code2: students.forEach(student=>{
                if(student.marks > 50)
                    below_average.push(student)
            })
    ```
  2. question figure
    text
    ```
    code1: actions
    code2: state.students.forEach(student=>{
        if(student.mark > 50)
    
            below_average.toppers.push(student)
    })
    ```
  3. question figure
    text
    ```
    code1: actions
    code2: context.students.forEach(student=>{
        if(student.marks < 55)
            context.below_average.push(student)
    })
    ```
  4. question figure
    text
    ```
    code1: mutations
    code2: state.students.forEach(student=>{
        if(student.marks > 50)
            state.below_average.push(student)
    })
    ```
Q20MCQ3 marks
Consider the following JavaScript code. question figure Consider the following JavaScript code. 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?
Text of the picture (copyable)
```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. Response is not json
  2. Network Error
  3. 200
  4. None of these
Q21MCQ3 marks
Consider the JavaScript code. Suppose the ‘url’ returns a JSON response with 404 status code. What will be logged on to console? question figure Consider the JavaScript code. Suppose the ‘url’ returns a JSON response with 404 status code. What will be logged on to console?
Text of the picture (copyable)
```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. Response is not json
  2. Network Error
  3. 404
  4. None of these
Q22MCQ3 marks
Consider the following JavaScript code. question figure Consider the following JavaScript code. What will be logged on to console, if executed?
Text of the picture (copyable)
```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())
```
  1. NaN
  2. 500
  3. 2500
  4. Some Error
Q23MCQ3 marks
question figure question figure question figure
Text of the picture (copyable)
Consider the following Vue application with Javascript "app.js" and markup "index.html"
Suppose the application is running on "http://127.0.0.1:8080/". Suppose the user clicks on
"Increase count" button associated with the item name "Apple" 10 times then clicks on
"Add To Cart" and then clicks on the button "Buy". What will be logged on to console?
app.js
```javascript
new Vue({
  el: '#app',
  template: `
    <div v-for="item in items">
      Name:{{item.name}}, Count:{{item.count}}, Price:
      {{item.price*item.count}}
      <button @click="inscreeseCount(item)">Increase Count</button>
      <button @click="addToCart(item)">Add To Cart</button>
    </div>
    Total Amount: {{amount}} <button @click="buy"> Buy </button>
  `,
  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>
```
  1. Success
  2. Failure
  3. NaN
  4. None of these
Q24MCQ3 marks
question figure question figure
Text of the picture (copyable)
Consider the Vue application mentioned. What will be rendered by the browser for the URL "http://127.0.0.1:8080/#/dashboard/2"?
```javascript
app.js
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
<body>
  <div id="app"></div>
</body>
```
  1. This is dashboard of User
  2. This is dashboard of 2
  3. Dashboard
  4. Result Not Found
Q25MCQ3 marks
question figure question figure
Text of the picture (copyable)
Consider the flask application mentioned. Suppose the application is
running on "http://localhost:5000". If user1 visits the URL "http://localhost:5000" and
after 3 minutes user2 visits the same URL. What will be the approx difference between
the response time for user1 and user2?
```python
app.py
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. 0 seconds
  2. 30 seconds
  3. 120 seconds
  4. None of these
Q26MCQ3 marks
Consider the below javascript program. question figure Consider the below javascript program. What will be the output of the above program, if executed?
Text of the picture (copyable)
```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);
```
  1. Function Invoked !!2
  2. Function Invoked !!3
  3. Function Invoked !!1
  4. Function Invoked !!Error
  5. Error
Q27MCQ3 marks
Consider the following Vue application with markup “index.html” and javascript file “app.js”. question figure Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
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. This is from templateThis is from template
  2. This is from Rashmi’s templateThis is from Akshay’s templateThis is from Sumit’s template
  3. This is from Rashmi’s templateThis is from Sumit’s template
  4. This is from Rashmi’s templateThis is from Sumit’s templateThis is from Akshay’s template
  5. This is from templateThis is from templateThis is from template
Q28MCQ3 marks
Consider the below javascript program. question figure Consider the below javascript program.
Text of the picture (copyable)
```javascript
for (var i = 0; i < 3; i++) {
    setTimeout(() => console.log(i), (i+1)*2000);
}
```
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. question figure
    text
    ```text
    0
    1
    2
    Minimum Time Taken: 6 seconds
    ```
  2. question figure
    text
    0
    1
    2
    Minimum Time Taken: 12 seconds
  3. question figure
    text
    3
    3
    3
    Minimum Time Taken: 12 seconds
  4. question figure
    text
    3
    3
    3
    Minimum Time Taken: 6 seconds
Q29MCQ3 marks
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. Denial Of Service Attack
  2. CSRF Attack
  3. Flooding Attack
  4. None of these
Q30MCQ3 marks
Consider the below javascript program. question figure Consider the below javascript program. What will be the output of the above program, if executed?
Text of the picture (copyable)
```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");
```
  1. FirstSecondThird2
  2. FirstError
  3. FirstThirdSecondundefined
  4. FirstThirdSecond2
  5. The output cannot be predicted
Q31MCQ2 marks
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. v-for = “value in obj”
  2. v-for = “(value, name) in obj”
  3. v-for = “(value, name, index) in obj”
  4. All of these.
Q32MCQ2 marks
Which of the following statement(s) is/are true regarding Celery?
  1. A celery system may consist of multiple brokers.
  2. Redis must be used as a message broker for Celery.
  3. The framework does not support periodic scheduling of tasks.
  4. All of these.

Answer key

  1. Q1 (MSQ, 2 marks): A, D
  2. Q2 (MSQ, 2 marks): A, B, C
  3. Q3 (MSQ, 2 marks): A, C
  4. Q4 (MSQ, 2 marks): A, D
  5. Q5 (MSQ, 2 marks): B, D
  6. Q6 (MSQ, 2 marks): A, D
  7. Q7 (MSQ, 3 marks): A, B, C, D
  8. Q8 (MSQ, 3 marks): B, C
  9. Q9 (MSQ, 3 marks): A, C
  10. Q10 (MSQ, 3 marks): B, C
  11. Q11 (MSQ, 3 marks): A, B, C
  12. Q12 (MCQ, 4.5 marks): C
  13. Q13 (MCQ, 4.5 marks): C
  14. Q14 (MCQ, 4.5 marks): A
  15. Q15 (MCQ, 4.5 marks): D
  16. Q16 (MCQ, 4.5 marks): B
  17. Q17 (MCQ, 4.5 marks): E
  18. Q18 (MCQ, 4.5 marks): D
  19. Q19 (MCQ, 4.5 marks): D
  20. Q20 (MCQ, 3 marks): B
  21. Q21 (MCQ, 3 marks): C
  22. Q22 (MCQ, 3 marks): A
  23. Q23 (MCQ, 3 marks): B
  24. Q24 (MCQ, 3 marks): B
  25. Q25 (MCQ, 3 marks): A
  26. Q26 (MCQ, 3 marks): D
  27. Q27 (MCQ, 3 marks): C
  28. Q28 (MCQ, 3 marks): C
  29. Q29 (MCQ, 3 marks): B
  30. Q30 (MCQ, 3 marks): D
  31. Q31 (MCQ, 2 marks): D
  32. Q32 (MCQ, 2 marks): A