MAD Study Hub

Home / Past papers / MAD2 End Term / this paper

IIT M DIPLOMA AN EXAM QDD4 13 Apr 2025 - 13 Apr 2025

MAD2 End Term32 questions100 marks26 MCQ · 4 MSQ · 2 SADiploma / afternoon / QDD4
Elapsed 00:00
Q1MCQ2 marks
Which of the following statements is true regarding the "this" keyword in JavaScript?
  1. "this" always refers to the function it is declared in.
  2. Arrow functions inherit "this" from their enclosing lexical scope.
  3. "this" inside a class method always refers to the window object.
  4. None of these
Q2MCQ2 marks
Which of the following correctly describes the lifecycle of a Vue.js component?
  1. beforeCreate -> created -> beforeMount -> mounted -> beforeUpdate ->updated -> beforeUnmount -> unmounted
  2. beforeCreate -> created -> beforeMount -> beforeUpdate -> mounted ->updated -> beforeUnmount -> unmounted
  3. created -> beforeCreate -> beforeMount -> mounted -> updated ->beforeUnmount -> unmounted
  4. created -> beforeCreate -> beforeMount -> mounted -> beforeUnmount ->updated -> unmounted
Q3MCQ2 marks
question figure
Text of the picture (copyable)
Consider the below JavaScript program.

```javascript
const promise = new Promise(((resolve, reject) => {
  reject('Error!');
  resolve('Success!');
}));
promise.then(console.log).catch(console.log);
```

What will be the output of the above program?
  1. Success!Failed!
  2. Success!
  3. Failed!
  4. Error!
Q4MCQ2 marks
What is the main advantage of using JWT over session-based authentication?
  1. JWTs require storing tokens on the server, reducing security risks.
  2. JWTs are stateless and do not require server-side storage.
  3. JWTs are shorter and more efficient than session IDs.
  4. JWTs automatically expire and require no further security measures.
Q5MCQ2 marks
Which of the following HTTP methods does SSE use for streaming updates to clients?
  1. GET
  2. POST
  3. PUT
  4. PATCH
Q6MCQ2 marks
How does a webhook differ from an API call?
  1. A webhook is triggered by an event, while an API call requires a client request.
  2. A webhook always returns a response body, while an API call does not.
  3. A webhook uses WebSockets for communication, while APIs use REST.
  4. A webhook only supports the HTTP GET method.
Q7MCQ2 marks
What is the purpose of CORS in web security?
  1. To allow browsers to make requests to any domain without restrictions.
  2. To prevent the server from making requests to unauthorized origins.
  3. To allow a web application to request resources from a different domainsecurely.
  4. To restrict all incoming requests to the same domain.
Q8MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below JavaScript program.

```javascript
let arr = [4, 5, 6];
let sum = arr.reduce((acc, val, idx, array) => acc + (array[idx - 1] || 0),
0);
console.log(sum);
```

What will be the output of the above program?
  1. 6
  2. NaN
  3. undefined
  4. 9
  5. 15
Q9MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below JavaScript program.

```javascript
const obj = {
  num: 8,
  multiply: function () {
    return this.num * 3;
  },
};
const multiply = obj.multiply.bind({ num: 2 });
console.log(multiply());
```

What will be the output of the above program?
  1. 24
  2. 6
  3. NaN
  4. NULL
  5. Error
Q10MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below Vuex store configuration:

```javascript
const store = new Vuex.Store({
  state: {
    items: ['Vue', 'React'],
  },
  mutations: {
    removeItem(state, item) {
      state.items = state.items.filter(i => i !== item);
    },
  },
  actions: {
    removeItemAsync({ commit }, item) {
      setTimeout(() => {
        commit('removeItem', item);
      }, 500);
    },
  },
});
```

If the addItemAsync action is dispatched with the item 'Vue', what will be the state of items after 2 seconds?
  1. []
  2. [ 'Vu', 'React' ]
  3. [ 'React' ]
  4. [ object ]
Q11MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below Vue app.

```html
<div id="app">
  <router-link to="/home">Go to Home</router-link>
  <router-view></router-view>
</div>

<script>
  const Home = { template: '<div>Home</div>' };
  const About = { template: '<div>About</div>' };

  const routes = [
    { path: '/home', component: Home },
    { path: '/about', component: About },
    { path: '*', redirect: '/home' }
  ];

  const router = new VueRouter({ routes });

  new Vue({
    el: '#app',
    router
  });
</script>
```

What happens when the user navigates to an undefined route like "/random"?
  1. Browser navigates to /random and shows a blank page.
  2. Browser navigates to /random but renders nothing.
  3. Browser redirects to /home and displays "Home".
  4. Error: No matching route.
Q12MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Vue component:

```javascript
Vue.component('search-component', {
  data() {
    return {
      searchQuery: ''
    }
  },
  watch: {
    searchQuery(newQuery, oldQuery) {
      this.fetchResults(newQuery)
    }
  },
  methods: {
    fetchResults(query) {
      // Fetch search results
    }
  }
})
```

Which of the following statements is true?
  1. The fetchResults method will be called immediately when the component iscreated.
  2. The fetchResults method will be called only when searchQuery changes.
  3. The watch property can detect changes even if the new value is the same asthe old value.
  4. All of these.
Q13MCQ3 marks
Which scenario is best suited for a task queue system like Celery or RabbitMQ?
  1. A real-time chat application that requires low-latency message delivery.
  2. A weather API that provides instant weather data upon request.
  3. A system where a webhook sends an immediate notification to a client whenan event occurs.
  4. A system where a user uploads a video, and it needs to be processedasynchronously.
Q14MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code.

```javascript
function processArray(arr) {
  let result = arr.filter(item => item > 5)
    .map(item => item * 2)
    .reduce((sum, item) => sum + item, );
  return result;
}
```

What will be returned when processArray([2, 6, 4, 8, 3]) is called?
  1. [12, 16]
  2. 28
  3. 46
  4. [6, 8]
Q15MCQ3 marks
question figure
Text of the picture (copyable)
Examine the following JavaScript code.

```javascript
function processData() {
  let data = [1, 2, 3, 4];
  let result = data.forEach(item => {
    if (item % 2 === 0) {
      return item * 10;
    }
  });
  return result;
}
```

What will be returned when processData() is called?
  1. [20, 40]
  2. [1, 20, 3, 40]
  3. [10, 20, 30, 40]
  4. undefined
Q16MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code.

```javascript
var value = 30;
const firstObj = {
  value: 10,
  displayValue: function() {
    return this.value;
  }
};

const secondObj = {
  value: 20
};

const displayValue1 = firstObj.displayValue.apply(secondObj);
const displayValue2 = firstObj.displayValue.apply();
const displayValue3 = function() {
  return firstObj.displayValue.apply(this);
}.call(secondObj);
const displayValue4 = firstObj.displayValue.bind(this)(20);

console.log("val1", displayValue1);
console.log("val2", displayValue2);
console.log("val3", displayValue3);
```

What will be the output of the above code on the browser's console?
  1. 10, 30, 20
  2. 20, undefined, 20
  3. 20, 30, 20
  4. 20, 30, 10
Q17MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code.

```javascript
export default {
  data() {
    return {
      loginToken: '',
    };
  },
  mounted() {
    this.loginToken = sessionStorage.getItem('authToken') || '';
  },
  methods: {
    updateToken(newToken) {
      this.loginToken = newToken;
      sessionStorage.setItem('authToken', newToken);
    }
  }
};
```

What will happen when a user calls the updateToken method with a new value and then refreshes the page?
  1. question figure
    text
    The new token will be lost, and the "loginToken" data property will be reset to an empty string.
  2. question figure
    text
    The new token will be preserved in session storage, and the "LoginToken" data property will be populated with the stored value on page refresh.
  3. question figure
    text
    The method will throw an error because sessionStorage cannot be modified directly.
  4. question figure
    text
    The "loginToken" data property will be updated, but the session storage will remain unchanged.
Q18MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below Vuex setup.

```javascript
const store = new Vuex.Store({
  state: {
    number: 10
  },
  mutations: {
    updateNumber(state, payload) {
      state.number = payload;
    }
  },
  actions: {
    async fetchNumber({ commit }) {
      const fetchedValue = await getData();
      commit('updateNumber', fetchedValue);
    }
  }
});

function getData() {
  return new Promise(resolve => {
    setTimeout(() => resolve(100), 1500);
  });
}

store.dispatch('fetchNumber');
console.log(store.state.number);
```

What is logged to the console immediately after dispatching the action?
  1. 0
  2. 10
  3. 100
  4. Undefined behavior
  5. Error: Action did not resolve
Q19MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below flask SSE implementation.

```python
from flask import Flask, Response
import time

app = Flask(__name__)

def event_stream():
    for i in range(5):
        yield f"data: Message {i}"
        time.sleep(1)

@app.route('/events')
def sse():
    return Response(event_stream(), mimetype="text/event-stream")
```

And the Vue.js frontend:

```html
<template>
  <div>
    <p v-for="msg in messages" :key="msg">{{ msg }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return { messages: [] };
  },
  mounted() {
    const eventSource = new EventSource("http://localhost:5000/events");
    eventSource.onmessage = (event) => {
      this.messages.push(event.data);
    };
  },
};
</script>
```

What will happen when a user opens this page?
  1. The client will receive 5 messages, one per second.
  2. The client will receive all 5 messages instantly.
  3. The client will not receive any messages due to CORS issues.
  4. The server will crash because Flask cannot handle SSE.
Q20MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Flask application (server.py) and an HTML file named index.html:

server.py
```python
from flask import Flask
import time

app = Flask(__name__)

@app.route("/api/slow1")
def slow_api_1():
    time.sleep(15)
    return "Response from Slow API 1", 200, {'Access-Control-Allow-Origin': '*'}

@app.route("/api/slow2")
def slow_api_2():
    time.sleep(25)
    return "Response from Slow API 2", 200, {'Access-Control-Allow-Origin': '*'}

if __name__ == "__main__":
    app.run(threaded=False)
```

index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Flask Fetch Example</title>
</head>
<body>
    <h1>Fetching API Data...</h1>

    <script>
        fetch("http://127.0.0.1:5000/api/slow1")
            .then(res => res.json())
            .then(data => console.log("API 1 Response:", data));

        fetch("http://127.0.0.1:5000/api/slow2")
            .then(res => res.json())
            .then(data => console.log("API 2 Response:", data));
    </script>
</body>
</html>
```

The application runs on http://localhost:5000.
A client makes two requests, one to http://localhost:5000/data/apple and another to http://localhost:5000/data/orange, both within 50 seconds.
What will be the approximate absolute difference between their latencies?
  1. 25 seconds
  2. 35 seconds
  3. 0 seconds
  4. 15 seconds
Q21MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue apps in script.js and the index.html file.

script.js

```javascript
const app1 = new Vue({
  el: '#app1',
  data: {
    value1: "VueJS",
    value2: "Frontend"
  }
})

const app2 = new Vue({
  el: '#app2',
  data: {
    value3: "JavaScript"
  }
})
```

index.html

```html
<div id="app2">
  {{value1}}
  <div id="app1">
    {{value2}}
  </div>
  {{value3}}
</div>
<script src="./script.js"></script>
```

What will be rendered on the browser?
  1. Frontend
  2. VueJSFrontend
  3. VueJSJavaScript
  4. FrontendJavaScript
Q22MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue App and the HTML document given below.

index.html
```html
<div id="app">
  <my-comp>
    <slot>Hello Frontend</slot>
    <slot>Hello VueJS</slot>
  </my-comp>
</div>
<script src="script.js"></script>
```

script.js
```javascript
const myComp = {
  template: `
    <div>
      <slot></slot>
      <slot></slot>
    </div>
  `
}

const app = new Vue({
  components: {
    "my-comp": myComp
  }
}).$mount('#app')
```

What will be the output on the browser?
  1. Hello Frontend Hello Frontend
  2. Hello VueJS Hello VueJS
  3. Hello Frontend Hello Vue JS
  4. Hello Frontend Hello Vue JS Hello Frontend Hello Vue JS
Q23MSQ2 marksselect all that apply
Which of the following is/are the correct usage of “v-for” directive in VueJS?
  1. item in array
  2. (item, index) of array
  3. (item, index) as array
  4. (item, index) in array
  5. Item of array
Q24MSQ3 marksselect all that apply
In a Single Page Application (SPA), what are the benefits of client-side routing over server-side routing?
  1. Faster navigation between pages
  2. Less strain on the backend server
  3. Improved SEO by default
  4. Full-page reloads occur on every navigation
Q25MSQ3 marksselect all that apply
In an SSE connection, how does the client handle incoming messages?
  1. The client polls the server at regular intervals.
  2. The client listens to a WebSocket stream.
  3. The client registers an “onmessage” event listener on the EventSource object.
  4. The client sends a POST request for each new event.
Q26MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following Vue Router configuration:

```javascript
const router = new VueRouter({
  routes: [
    { path: '/', component: Home },
    { path: '/user/:id', component: User },
    { path: '/about', component: About },
    { path: '*', component: NotFound }
  ]
})
```

Which URL/URLs would render the NotFound component?
  1. /user
  2. /user/123
  3. /contact
  4. /about/team
Q27SA4.5 marks
question figure
Text of the picture (copyable)
Consider the below Vuex store configuration.

```javascript
const store = new Vuex.Store({
  state: {
    count: 5,
  },
  mutations: {
    decrement(state) {
      state.count--;
    },
  },
});
```

And the below Vue component:

```html
<template>
  <div>
    <button @click="decrement">Decrement</button>
    <p>Count: {{ count }}</p>
  </div>
</template>

<script>
  import { mapState, mapMutations } from 'vuex';

  export default {
    computed: {
      ...mapState(['count']),
    },
    methods: {
      ...mapMutations(['decrement']),
    },
  };
</script>
```

What will be displayed in the placeholder "{{ count }}" on the browser after clicking the "Decrement" button 4 times?
Q28SA3 marks
question figure
Text of the picture (copyable)
How many times will "Render" be logged in the console when the Vue component below is mounted?

```html
<div id="app">
  <div>{{ computedValue }}</div>
</div>
<script>
  new Vue({
    el: "#app",
    data() {
      return { count: 0 };
    },
    computed: {
      computedValue() {
        console.log("Render");
        return this.count * 2;
      },
    },
    mounted() {
      this.count++;
      this.count++;
    },
  });
</script>
```
Comprehension passage - the questions below it refer to this
question figure
Q29MCQ3 marks
question figure
Text of the picture (copyable)
Which of the following statements
is correct for the following fetch
request.

```javascript
fetch("http://127.0.0.1:5000/protected", {
    method: "GET"
})
.then(response => {
    return response.json();
})
.then(data => console.log("Protected Route Response:", data))
.catch(error => console.error("Error:", error));
```
  1. question figure
    text
    The request will be processed
    successfully, and "Hello, student!"
    will be returned.
  2. question figure
    text
    The request will fail with a
    401 Unauthorized error.
  3. question figure
    text
    The request will return an empty
    response with a 200 OK status.
  4. question figure
    text
    The request will fail with a
    403 Forbidden error.
Q30MCQ4.5 marks
question figure
Text of the picture (copyable)
What will be the result of the
following fetch request.

```javascript
fetch("http://127.0.0.1:5000/protected", {
    method: "GET",
    headers: {
        "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.."
    }
})
.then(response => {
    if (response.status === 403) {
        throw new Error("403 Forbidden: Insufficient permissions");
    }
    return response.json();
})
.then(data => console.log("Protected Route Response:", data))
.catch(error => console.error("Error:", error));
```
  1. question figure
    text
    The request will be processed
    successfully, and "Hello, student!"
    will be returned.
  2. question figure
    text
    The request will fail with a
    401 Unauthorized error.
  3. question figure
    text
    The request will return an empty response with a 200 OK status.
  4. question figure
    text
    The request will fail with a
    403 Forbidden error.
Comprehension passage - the questions below it refer to this
Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions.
Q31MCQ4.5 marks
What will be rendered on the browser if the application is loaded on the browser for the first time?
  1. You are not logged in.
  2. Welcome to profile
  3. You are not authorized.
  4. None of these.
Q32MCQ3 marks
What will be rendered on the browser for the given value of localStorage? question figure What will be rendered on the browser for the given value of localStorage?
Text of the picture (copyable)
```json
{
  "token": 112,
  "userRole": "admin"
}
```
  1. You are not logged in.
  2. Welcome to profile
  3. You are not authorized.
  4. None of these.

Answer key

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

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Here’s a structured summary of the core topics, concepts, and principles essential for the "Diploma Level: Modern Application Development II" exam, along with a Mermaid knowledge graph to visualize relationships.



Core Topics & Concepts

1. JavaScript Fundamentals


2. Vue.js


3. Authentication & Security


4. Asynchronous Communication


5. Flask (Python Backend)


6. Single Page Applications (SPAs)


7. HTTP Methods


Key Equations (Mathematics/Logic)

No direct mathematical equations were present in the questions, but here are logical patterns relevant to the exam:

  1. Promise Resolution:

    • If both resolve and reject are called, the first call determines the outcome.
    • promise.then().catch() handles fulfillment/rejection.
  1. Array Reduce:

    • array.reduce((acc, val) => acc + val, initialValue)
    • Example: [1, 2, 3].reduce((acc, val) => acc + val, 0) // 6
  1. Vue Reactivity:

    • Computed properties are cached and only re-evaluate when dependencies change.

Graph 1: JavaScript & Vue.js Core Concepts

Graph 2: Authentication & Security

Graph 3: Asynchronous Communication


Exam Preparation Tips

  1. JavaScript:

    • Master this, promises, and array methods (reduce is tricky!).
    • Practice bind/call/apply scenarios.
  1. Vue.js:

    • Memorize the component lifecycle order.
    • Understand Vuex flow (state → mutations → actions → getters).
    • Know router configurations (wildcards, dynamic routes).
  1. Authentication:

    • Compare JWT vs. sessions (stateless vs. stateful).
    • Know where to store tokens (localStorage vs. sessionStorage).
  1. Asynchronous Patterns:

    • Differentiate SSE vs. WebSockets vs. Polling.
    • Understand task queues for background jobs.
  1. Flask:

    • Practice JWT integration and CORS setup.
    • Know how to handle asynchronous routes (e.g., time.sleep).
  1. Debugging:

    • For Vue.js, use Vue DevTools to inspect state and components.
    • For JavaScript, use console.log to track this and scope.

Final Note: Focus on practical coding scenarios (e.g., promise resolution, Vuex mutations, JWT flows) and diagram-based questions (e.g., component hierarchies, lifecycle hooks). The Mermaid graphs above should help you visualize connections between topics. Good luck!