MAD Study Hub

Home / MAD2 / Week 1 / Real questions

MAD2 week 1 - real exam questions

60 questions pulled from past papers whose wording matches this week's topics, newest first, duplicates removed. Pick your answers, then press Check answers. Figures and answer keys are the originals.

Elapsed 00:00
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 1MCQ4.5 marks
A startup is building a food delivery app. The customer-facing screen shows live order status updates: "Order Placed → Preparing → Out for Delivery → Delivered". Each stage is triggered by the restaurant or the delivery rider updating the status on their end. The customer's screen should reflect these changes in real time without refreshing the page. Two developers debate about the right technology: Developer A says: "Let's use Server-Sent Events. It's the right fit here." Developer B says: "No, we must use WebSockets. SSE won't work." Who is correct, and why?
  1. Developer B is correct. SSE cannot transmit JSON data, so structured order status objects cannot be pushed to the browser.
  2. Developer B is correct. SSE connections do not reconnect automatically when the network is briefly interrupted, making it unreliable for a live tracker.
  3. Developer A is correct, but only if WebSockets are set up as a mandatory fallback, since SSE requires HTTP/2 to function.
  4. Developer A is correct. The tracker only requires the server to push status updates to the customer, without the customer sending data back through the same connection. SSE is purpose-built for exactly this one-way server-to-client push scenario.
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 2MCQ4.5 marks
Consider the following and JavaScript for a Vue application: File: index.html question figure File: app.js question figure Suppose the application is running on , and the user visits the URL: What will be rendered by the browser? [NOTE: is divided in two images, consider them as one file content.] question figure
Text of the picture (copyable)
index.html
app.js
```html
<div id="app">
  <router-view></router-view>
</div>
```
```javascript
const Flights = {
  template: `<h2>{{ result }}</h2>`,

  data() {
    return {
      routes: [
        { city: "Delhi", connectedTo: ["Mumbai", "Pune"] },
        { city: "Indore", connectedTo: ["Bhopal", "Jaipur"] },
        { city: "Raipur", connectedTo: ["Nagpur", "Hyderabad"] },
        { city: "Rewa", connectedTo: ["Delhi", "Indore", "Raipur"] }
      ],
      result: ""
    };
  },

  created() {
    const destination = this.$route.params.city.toLowerCase();

    for (let i = 0; i < this.routes.length; i++) {
      const connections = this.routes[i].connectedTo;

      for (let j = 0; j < connections.length; j++) {
        if (connections[j].toLowerCase() === destination) {
          this.result = this.routes[i].city;
          break;
        }
      }

      if (this.result) {
        break;
      }
    }
  }
};
```
```
http://localhost:8080
```
```
http://localhost:8080/#/raipur
```
app.js
```javascript
const router = new VueRouter({
  routes: [
    {
      path: "/:city",
      component: Flights
    }
  ]
});

new Vue({
  el: "#app",
  router
});
```
  1. Delhi
  2. Indore
  3. Raipur
  4. Rewa
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 3MCQ4.5 marks
Consider the following Vuex store: question figure The getter is used in a Vue component as shown below: question figure Now suppose the Vuex getter is removed, while the temperature state continues to be updated through Vuex mutations. Which of the following implementations correctly recreates in the component so that it automatically reacts whenever the Vuex changes?
Text of the picture (copyable)
```javascript
const store = new Vuex.Store({
  state: {
    temperature: 30
  },
  getters: {
    weatherStatus(state) {
      return state.temperature >= 35 ? "Hot" : "Normal"
    }
  }
})
```
weatherStatus
```javascript
computed: {
  weatherStatus() {
    return this.$store.getters.weatherStatus
  }
}
```
weatherStatus
weatherStatus
temperature
  1. question figure
    text
    ```javascript
    computed: {
      weatherStatus() {
        return this.$store.state.temperature >= 35
          ? "Hot"
          : "Normal"
      }
    }
    ```
  2. question figure
    text
    ```javascript
    watch: {
      weatherStatus() {
        return this.$store.state.temperature >= 35
          ? "Hot"
          : "Normal"
      }
    }
    ```
  3. question figure
    text
    ```javascript
    methods: {
      weatherStatus() {
        this.$store.state.temperature >= 35
          ? "Hot"
          : "Normal"
      }
    }
    ```
  4. question figure
    text
    ```javascript
    watch: {
      weatherStatus() {
        return this.$store.state.temperature >= 35
      }
    }
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 4MCQ3 marks
Consider the following JavaScript code: question figure What will be output on the browser’s console?
Text of the picture (copyable)
```javascript
function outerFunc() {
  const val1 = 10;
  var val2 = 20;

  function innerFunc() {
    var val2 = 30;
    console.log(val1)
    console.log(val2)
  }
  innerFunc()
  console.log(val1)
  console.log(val2)
}
outerFunc()
```
  1. question figure
    text
    ```
    10 20
    10 30
    ```
  2. question figure
    text
    ```
    10 20
    10 20
    ```
  3. question figure
    text
    ```
    10 30
    10 20
    ```
  4. None of these.
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 5MCQ3 marks
What is logged to the console after running the following code? question figure
Text of the picture (copyable)
```javascript
const numbers = [10, 20, 30, 40, 50];
const [num1, , num2, ...rest] = numbers;
const [a = 100, b = 200] = [undefined, 0];

console.log(num1, num2, rest);
console.log(a, b);
```
  1. 10 30 [30, 40, 50] and 100 0
  2. 10 30 [40, 50] and 100 200
  3. 10 20 [30, 40, 50] and undefined 0
  4. 10 30 [40, 50] and 100 0
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 6MCQ3 marks
What is logged to the console after running the following code? question figure
Text of the picture (copyable)
```javascript
const user = {
  id: 1,
  profile: {
    name: "Riya",
    address: {
      city: "Pune",
      zip: "411001"
    }
  }
};

const {
  profile: {
    name,
    address: { city, state = "Maharashtra" }
  },
  role = "guest",
  profile
} = user;

console.log(name, city, state, role);
console.log(profile);
```
  1. text
    Riya Pune Maharashtra guest
    ```
    { name: "Riya", address: { city: "Pune", zip: "411001" } }
    ```
  2. text
    Riya Pune Maharashtra guest
    undefined
  3. text
    ```
    undefined undefined Maharashtra guest
    ```
    ```json
    { "name": "Riya", "address": { ...} }
    ```
  4. This code throws a , because you cannot destructure profile into nested variables and also assign it to a plain variable profile in the same statement.
    text
    SyntaxError
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 7MCQ3 marks
Consider the following JavaScript code: question figure What is the order of console output?
Text of the picture (copyable)
```javascript
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");
Promise.resolve().then(() => {
  console.log("5");
  setTimeout(() => console.log("6"), 0);
});
```
  1. 1, 4, 3, 5, 2, 6
  2. 1, 4, 3, 5, 6, 2
  3. 1, 3, 4, 5, 2, 6
  4. 1, 4, 2, 3, 5, 6
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 8MCQ3 marks
Match each Vue directive with its correct description: question figure
Text of the picture (copyable)
| Directive | Description |
|---|---|
| 1. v-if | A. Two-way binding between input and data |
| 2. v-for | B. Conditionally renders DOM elements |
| 3. v-bind | C. Binds HTML attributes dynamically |
| 4. v-model | D. Renders a list of items |
  1. 1–A, 2–D, 3–C, 4–B
  2. 1–D, 2–B, 3–C, 4–A
  3. 1–B, 2–D, 3–C, 4–A
  4. 1–B, 2–C, 3–D, 4–A
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 9MSQ3 marksselect all that apply
Given the following code, select all the statements that are TRUE about its execution if the code is run in a browser environment. question figure
Text of the picture (copyable)
```javascript
const calculator = {
  value: 10,
  add(a, b) {
    return this.value + a + b;
  }
};

const rawAdd = calculator.add;
const boundAdd = calculator.add.bind({ value: 100 }, 5);

console.log(rawAdd(1, 2));
console.log(boundAdd(10));
console.log(calculator.add.apply({ value: 50 }, [1, 2]));
```
  1. evaluates to
    text
    ```
    rawAdd(1, 2)
    ```
    NaN
  2. evaluates to
    text
    ```
    boundAdd(10)
    ```
    115
  3. evaluates to
    text
    ```
    calculator.add.apply({ value: 50 }, [1, 2])
    ```
    53
  4. throws a
    text
    ```
    calculator.add.apply({ value: 50 }, [1, 2])
    ```
    TypeError
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 10MSQ4.5 marksselect all that apply
Given the following code running in the browser, select all the statements that are about its output: question figure question figure
Text of the picture (copyable)
TRUE
```javascript
const value = "global";

const obj = {
  value: "objectValue",
  regularMethod: function () {
    console.log(this.value);
  },
  arrowMethod: () => {
    console.log(this.value);
  },
  nested: {
    value: "nestedValue",
    regularInNested: function () {
      console.log(this.value);
    },
    arrowInNested: () => {
      console.log(this.value);
    },
  },
  delayedRegular: function () {
    setTimeout(function () {
      console.log(this.value);
    }, 100);
  },
  delayedArrow: function () {
    setTimeout(() => {
      console.log(this.value);
    }, 100);
  },
};
```
```javascript
obj.regularMethod();
obj.arrowMethod();
obj.nested.regularInNested();
obj.nested.arrowInNested();
obj.delayedRegular();
obj.delayedArrow();
```
  1. logs "objectValue"
    text
    ```
    obj.regularMethod()
    ```
  2. logs "objectValue"
    text
    ```
    obj.arrowMethod()
    ```
  3. logs "nestedValue"
    text
    ```
    obj.nested.regularInNested()
    ```
  4. logs
    text
    ```
    obj.nested.arrowInNested()
    ```
    undefined
  5. logs "objectValue"
    text
    ```
    obj.delayedArrow()
    ```
  6. logs "objectValue"
    text
    ```
    obj.delayedRegular()
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 11MCQ2 marks
Comprehension passage for this question
Consider the following javascript code: question figure Note: Each sub question runs on its own, starting from the original 'user' object. Based on the above data, answer the given subquestions.
What will be logged in the console ? question figure
Text of the picture (copyable)
```javascript
const cloned = { ...user }

cloned.name = "Amit"
cloned.skills.push("JavaScript")

console.log(user.name)
console.log(user.skills.length)
```
  1. Rahul 2
  2. Amit 3
  3. Rahul 3
  4. Amit 2
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 12MCQ3 marks
Comprehension passage for this question
Consider the following javascript code: question figure Note: Each sub question runs on its own, starting from the original 'user' object. Based on the above data, answer the given subquestions.
What will be logged in the console ? question figure
Text of the picture (copyable)
```javascript
const cloned = {
  ...user,
  skills: [...user.skills]
}

cloned.skills.push("JavaScript")

console.log(user.skills.length)
console.log(cloned.skills.length)
```
  1. 2 3
  2. 3 3
  3. 2 2
  4. 3 2
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 13MSQ3 marksselect all that apply
Comprehension passage for this question
Consider the following JavaScript code: question figure Based on the above data, answer the given subquestions.
Which of the following statements are correct?
  1. pauses the execution of the function until the Promise resolves.
    text
    await
    ```
    display()
    ```
  2. immediately returns the resolved string "Data Received".
    text
    ```
    fetchData()
    ```
  3. functions cannot return a .
    text
    async
    Promise
  4. Removing would cause to store a object instead of the resolved value.
    text
    await
    result
    Promise
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 14MSQ4.5 marksselect all that apply
Read the following component code carefully. file: script.js question figure file:index.html question figure Select all statements that correctly describe the console output:
Text of the picture (copyable)
```javascript
new Vue({
  el: "#app",
  data: {
    message: "Hello"
  },
  beforeCreate() {
    console.log("1:", this.message);
  },
  created() {
    console.log("2:", this.message);
  },
  beforeMount() {
    console.log("3:", this.$el.textContent);
  },
  mounted() {
    console.log("4:", this.$el.textContent);
  }
});
```
```html
<div id="app">{{ message }}</div>
```
  1. Log 1: prints
    text
    undefined
  2. Log 2: prints
    text
    hello
  3. Log 3: prints
    text
    hello
  4. Log 4: prints
    text
    hello
  5. Log 3: throws an error because $el is not yet available
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 15MSQ4.5 marksselect all that apply
A Vue 2 application fetches a list of courses from an API and wants to display them in the template. question figure Assume the API returns: question figure Complete the missing code so that all course names are rendered correctly. Which of the following code snippets can correctly replace ?
Text of the picture (copyable)
```html
<div id="app">
  <ul>
    <!-- Missing Code -->
  </ul>
</div>

<script>
  new Vue({
    el: '#app',

    data: {
      courses: []
    },

    async mounted() {
      const response = await fetch('https://example.com/api/courses')
      this.courses = await response.json()
    }
  })
</script>
```
```json
[
  { "id": 1, "name": "MAD-2" },
  { "id": 2, "name": "DBMS" }
]
```
```html
<!-- Missing Code -->
```
  1. question figure
    text
    ```html
    <li v-for="course in courses" :key="course.id">
      {{ course.name }}
    </li>
    ```
  2. question figure
    text
    ```html
    <li v-for="(course, index) in courses" :key="index">
      {{ course.name }}
    </li>
    ```
  3. question figure
    text
    ```html
    <li v-if="course in courses">
      {{ course.name }}
    </li>
    ```
  4. question figure
    text
    ```html
    <li v-for="courses in course">
      {{ courses.name }}
    </li>
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 16MCQ3 marks
What is the value of result after running the following code? question figure
Text of the picture (copyable)
```javascript
const products = [
  { name: "Laptop", price: 1200, inStock: true },
  { name: "Mouse", price: 25, inStock: false },
  { name: "Keyboard", price: 75, inStock: true },
  { name: "Monitor", price: 300, inStock: false }
];

const result = products.filter(item => item.inStock && item.price < 500);
```
  1. text
    ```json
    { "name": "Keyboard", "price": 75, "inStock": true }
    ```
  2. text
    ```
    [[{ name: "Laptop", price: 1200, inStock: true }, { name: "Keyboard", price: 75, inStock: true }]]
    ```
  3. text
    ```
    [[{ name: "Keyboard", price: 75, inStock: true }]]
    ```
  4. text
    ```html
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .box {
                width: 100px;
                height: 100px;
                background-color: lightblue;
                margin: 10px;
                border: 1px solid black;
            }
            .container {
                display: flex;
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: flex-start;
                align-items: flex-start;
                align-content: flex-start;
                height: 300px;
                border: 2px solid red;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="box">Box 1</div>
            <div class="box">Box 2</div>
            <div class="box">Box 3</div>
            <div class="box">Box 4</div>
            <div class="box">Box 5</div>
            <div class="box">Box 6</div>
        </div>
    </body>
    </html>
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 17MCQ3 marks
A developer runs the following code in Tab 1 of a browser, then opens the same website in a new Tab 2 (not a duplicate, but a fresh tab typed into the address bar). question figure Which of the following statements correctly describes what happens in Tab 2?
Text of the picture (copyable)
```javascript
// Executed in Tab 1
localStorage.setItem("theme", "dark");
sessionStorage.setItem("cart", "3-items");
```
  1. Both and return their respective values.
    text
    ```javascript
    localStorage.getItem("theme")
    ```
    ```javascript
    sessionStorage.getItem("cart")
    ```
  2. returns "dark", but returns null.
    text
    ```javascript
    localStorage.getItem("theme")
    ```
    ```javascript
    sessionStorage.getItem("cart")
    ```
  3. Both return null
  4. returns "3-items", but returns null.
    text
    ```javascript
    sessionStorage.getItem("cart")
    ```
    ```javascript
    localStorage.getItem("theme")
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 18MCQ2 marks
Comprehension passage for this question
Consider the following JavaScript code: question figure Based on the above data, answer the given subquestions.
What will be printed in the console?
  1. Normal: Rahul Arrow: Rahul
  2. Normal: Arrow: Rahul
  3. Normal: Rahul Arrow: undefined
  4. Normal: Arrow:
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 19MSQ3 marksselect all that apply
Comprehension passage for this question
Consider the following JavaScript code: question figure Based on the above data, answer the given subquestions.
Which of the following statements correctly explain the behaviour of the code?
  1. The callback inside gets its own binding.
    text
    ```javascript
    setTimeout(function(){})
    ```
    this
  2. Arrow functions inherit from the surrounding lexical scope.
    text
    this
  3. automatically binds to the surrounding object.
    text
    ```
    setTimeout
    ```
    this
  4. If we use an arrow function inside in , it will print "Rahul".
    text
    ```
    setTimeout
    ```
    ```
    normalFunction
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 20MCQ2 marks
Comprehension passage for this question
Read the following Vue 2 component code carefully and answer the given subquestions: index.html question figure
What text appears on the button when the app first renders?
  1. "Hello"
  2. "Click Me"
  3. "" (empty)
  4. undefined
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 21MCQ3 marks
Comprehension passage for this question
Read the following Vue 2 component code carefully and answer the given subquestions: index.html question figure
After the button is clicked once, what is the value of log in the parent?
  1. "Hello"
  2. "Click Me"
  3. "Button clicked"
  4. undefined
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 22MCQ2 marks
A developer opens the Node.js REPL and runs the following line: question figure Why does this fail?
Text of the picture (copyable)
```javascript
const heading = document.querySelector("h1")
```
  1. Node.js cannot execute JavaScript from the terminal.
  2. The Node.js runtime does not provide browser DOM APIs like
    text
    document
  3. works only after using
    text
    ```javascript
    document.querySelector()
    ```
    ```
    setTimeout()
    ```
  4. V8 can execute only arithmetic expressions, not DOM code.
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 23MCQ2 marks
Consider the following javascript code: question figure The above code is initially loaded on the browser and then the browser is refreshed two times. What will be the final output?
Text of the picture (copyable)
```javascript
function addProduct(product) {
    let products = JSON.parse(localStorage.getItem('products')) || [];
    products.push(product);
    localStorage.setItem('products', JSON.stringify(products));
}

function getProducts() {
    return JSON.parse(localStorage.getItem('products')) || [];
}

addProduct({ id: 3, name: 'Tablet' }.name);
console.log(getProducts());
```
  1. ['Tablet', 'Tablet']
  2. ['Tablet', 'Tablet', 'Tablet']
  3. [{ id: 3, name: 'Tablet' }]
  4. [undefined]
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 24MCQ2 marks
Point out the error with the following code that is used to display user data? question figure
Text of the picture (copyable)
```javascript
async function getUser() {
  const response = await fetch("https://api.example.com/user/1");

  if (!response.ok) {
    throw new Error("Request failed");
  }

  const data = await response.json();
  console.log(data.name);
}

getUser();
```
  1. should use POST method by default, not GET
    text
    ```
    fetch()
    ```
  2. and will throw errors because response is a
    text
    response.ok
    ```
    response.json()
    ```
    Promise
  3. cannot be called on a response; use instead
    text
    ```
    .json()
    ```
    fetch
    ```
    .text()
    ```
  4. does not work inside functions
    text
    ```
    fetch()
    ```
    async
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 25MCQ3 marks
What is the correct output order for the following code? question figure
Text of the picture (copyable)
```javascript
console.log("A")
setTimeout(() => console.log("B"), 0)
Promise.resolve().then(() => console.log("C"))
console.log("D")
```
  1. A B C D
  2. C A D B
  3. A D C B
  4. A D B C
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 26MCQ3 marks
Consider the following code: question figure What happens to ?
Text of the picture (copyable)
```javascript
const settings = { theme: "light", layout: { sidebar: true } }
const copy = { ...settings }
copy.layout.sidebar = false
```
```
settings.layout.sidebar
```
  1. It remains because spread syntax always creates a deep copy.
    text
    true
  2. It becomes because the nested object is still shared in a shallow copy.
    text
    false
  3. It becomes because is removed from the original object.
    text
    undefined
    layout
  4. The code throws an error because nested objects cannot be copied with spread syntax.
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 27MCQ3 marks
Consider the following JavaScript code snippet? question figure What will be the output of above code on the browser’s console?
Text of the picture (copyable)
```javascript
async function fetchData() {
  console.log("1");
  const result = await new Promise((resolve) => {
    setTimeout(() => resolve("done"), 1000);
    console.log("2");
  });

  console.log("3:", result);
}

fetchData();
console.log("4");
```
  1. 1 → 2 → 3: done → 4
  2. 1 → 4 → 2 → 3: done
  3. 1 → 2 → 4 → 3: done
  4. 1 → 2 → 4 (3 never prints due to unresolved promise)
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 28MCQ3 marks
Consider the following Vuex store snippets. Which of the following demonstrates the correct usage of a mutation as per its definition?
  1. question figure
    text
    ```
    mutations: {
      ADD_TO_CART(state, product) {
        state.cart.push(product)
      }
    }
    ```
  2. question figure
    text
    ```javascript
    mutations: {
      ADD_TO_CART(state, product) {
        setTimeout(() => {
          state.cart.push(product)
        }, 500)
      }
    }
    ```
  3. question figure
    text
    ```javascript
    mutations: {
      ADD_TO_CART(state, product) {
        fetch('/api/add').then(() => {
          state.cart.push(product)
        })
      }
    }
    ```
  4. question figure
    text
    ```javascript
    mutations: {
      ADD_TO_CART(state, product) {
        Promise.resolve().then(() => {
          state.cart.push(product)
        })
      }
    }
    ```
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 29MSQ3 marksselect all that apply
Suppose the following HTML exists: question figure Which of the following statements are correct?
Text of the picture (copyable)
```html
<div class="card" data-price="499">
    <span id="title">Vue Book</span>
</div>
```
  1. returns .
    text
    ```javascript
    document.querySelector(".card").dataset.price
    ```
    "499"
  2. converts the value to numeric .
    text
    ```javascript
    Number(document.querySelector(".card").dataset.price)
    ```
    499
  3. can read the visible text .
    text
    ```javascript
    document.getElementById("title").innerText
    ```
    "Vue Book"
  4. returns a single element, not a collection.
    text
    ```javascript
    document.querySelectorAll(".card")
    ```
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 30MSQ4.5 marksselect all that apply
A Vue 2 component does the following: •loads initial task data from an API, •starts a timer after the component appears on the page, •clears that timer before the component is removed. Which hook choices are appropriate?
  1. for loading initial data.
    text
    ```
    created()
    ```
  2. for starting DOM-related work or timers.
    text
    ```
    mounted()
    ```
  3. for cleanup.
    text
    ```
    beforeDestroy()
    ```
  4. for declaring reactive .
    text
    ```
    destroyed()
    ```
    data
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 31MSQ2 marksselect all that apply
In a Vue Router app, a developer uses: • inside a parent route, • , • inside a method. Which statements are correct?
Text of the picture (copyable)
children
```
{ path: '*', component: NotFound }
```
```javascript
this.$router.go(-1)
```
  1. can be used to organize nested routes under a parent route.
    text
    children
  2. can act as a fallback for unknown routes.
    text
    *
  3. tries to go back one step in browser history.
    text
    ```javascript
    this.$router.go(-1)
    ```
  4. Vue Router removes the need for route components.
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 32MCQ4.5 marks
Fill in Code1, inside a mutation handler, which can be used to reduce the price of each of the products in the state by a certain discount. app.js: question figure
Text of the picture (copyable)
```javascript
const store = new Vuex.Store({
  state: {
    discount: 10,
    products: [
      {name: 'apple',
        price: 120
      },
      {
        name: 'banana',
        price: 60
      }
    ]
  },
  mutations: {
    reducePrice: state=>{
      // Code1
    }
  }
})
```
  1. text
    ```javascript
    this.$store.state.products.forEach(product => { product.price -= (state.discount)/100*product.price; })
    ```
  2. text
    ```javascript
    state.products.forEach(product => { product.price -= (state.discount)/100*product.price;})
    ```
  3. text
    ```javascript
    commit.products.forEach(product => { product.price -= (state.discount)/100*product.price;})
    ```
  4. text
    ```javascript
    dispatch.products.forEach(product => { product.price -= (state.discount)/100*product.price;})
    ```
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 33MCQ4.5 marks
Consider the following Vuex store and component code. store.js question figure Component.vue question figure After triggering all three methods ( , and ) one by one, which of the following statements is correct?
Text of the picture (copyable)
```javascript
const store = new Vuex.Store({
  state: {
    cart: []
  },
  mutations: {
    ADD_TO_CART(state, product) {
      state.cart.push(product)
    }
  },
  actions: {
    addToCart({ commit }, product) {
      setTimeout(() => {
        commit('ADD_TO_CART', product)
      }, 500)
    }
  }
})
```
```javascript
methods: {
  addItem_A(product) {
    this.$store.commit('ADD_TO_CART', product)
  },
  addItem_B(product) {
    this.$store.dispatch('addToCart', product)
  },
  addItem_C(product) {
    this.$store.state.cart.push(product)
  }
}
```
addItem_A
addItem_B
addItem_C
  1. All three methods will update the cart and all changes will be visible in Vue DevTools mutation history.
  2. Only and will appear in Vue DevTools mutation history, but will appear with a delay.
    text
    addItem_A
    addItem_B
    addItem_B
  3. Only will update the cart because mutations cannot be called directly from components.
    text
    addItem_B
  4. will throw an error because Vuex prevents direct state modification.
    text
    addItem_C
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 34MCQ4.5 marks
Read the following component carefully. question figure What will be logged in the console when this component first loads?
Text of the picture (copyable)
```html
<template>
  <div>
    <p>{{ message }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      message: ""
    };
  },
  beforeCreate() {
    console.log("A:", this.message);
  },
  created() {
    console.log("B:", this.message);
    this.message = "Hello from Vue!";
  },
  mounted() {
    console.log("C:", document.querySelector("p").textContent);
  }
};
</script>
```
  1. text
    A: "" → B: Hello from Vue! → C: Hello from Vue!
  2. text
    A: undefined -> B: Hello from Vue! -> C: Hello from Vue!
  3. text
    A: undefined → B: "" → C: Hello from Vue!
  4. text
    A: undefined → B: undefined → C: Hello from Vue!
  5. text
    A: "" -> B: "" -> C: Hello from Vue!
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 35MSQ2 marksselect all that apply
Consider running the following in Browser console: question figure Which of the following statements are correct?
Text of the picture (copyable)
```javascript
console.log(typeof setTimeout)
console.log(typeof document)
```
  1. The first line prints .
    text
    "function"
  2. The second line prints .
    text
    "undefined"
  3. will work in Browser by default because V8 provides the DOM.
    text
    ```javascript
    document.querySelector()
    ```
  4. Different runtimes (browser, Node.js, etc.) can provide different APIs even if they use the same JavaScript engine.
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 36MSQ2 marksselect all that apply
Which of the following are advantages of component-based frontend frameworks like Vue.js?
  1. Code reusability
  2. Better maintainability
  3. Automatic SQL query optimization
  4. Easier UI management
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 37MSQ2 marksselect all that apply
Which of the following cases is a function being used as a callback?
  1. question figure
    text
    ```javascript
    items.forEach(item => console.log(item))
    ```
  2. question figure
    text
    ```javascript
    setTimeout(showMessage, 1000)
    ```
  3. text
    ```javascript
    const result = showMessage()
    ```
  4. question figure
    text
    ```javascript
    button.addEventListener("click", handleClick)
    ```
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 38MCQ3 marks
What is the correct output order for the following code? question figure
Text of the picture (copyable)
```javascript
console.log("1")

setTimeout(() => {
  console.log("2")
  setTimeout(() => console.log("3"), 0)
}, 0)

console.log("4")
```
  1. 1 2 3 4
  2. 1 4 2 3
  3. 2 1 4 3
  4. 4 1 2 3
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 39MCQ3 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
let var1 = 20;
var var2 = 30;
const val = 10;

{
    let var1 = 40;
    console.log(var1 + val);
}

console.log(var1 + val);

{
    var var2 = 50;
    console.log(var2 + val);
}

console.log(var2 + val);
```
  1. 50 50 60 40
  2. 50 50 60 60
  3. 50 30 60 60
  4. 50 30 60 40
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 40MCQ3 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
const obj1 = {
    prop1: "Germany",
    prop2: "Spain",
    prop3: 50,
    method1: function(){
        console.log(`The European countries are ${this.prop2} and ${this.prop1}.`)
    },
    method2: function(param){
        let value = param + 2*this.prop3;
        console.log(`The final numerical value is: ${value}.`)
    }
}

const obj2 = {
    prop1: "England",
    prop2: "Italy",
    prop3: "25"
}

const func1 = obj1.method1;
const func2 = obj1.method2;

func1.apply(obj1);
func2.bind(obj2)(15);
```
  1. The European countries are Spain and Germany. The final numerical value is: 115.
  2. The European countries are Italy and England. The final numerical value is: 65.
  3. The European countries are Spain and Germany. The final numerical value is: 65.
  4. The European countries are Italy and England. The final numerical value is: 115.
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 41MCQ3 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
const obj1 = {
    prop1: "Aluminium",
    prop2: "Gold",
    prop3: "Silver"
}

const obj2 = {
    propA: "Argon",
    propB: "Neon"
}

const {prop2: element1, propA: element2} = {...obj2, ...obj1};

console.log(`The selected elements are: ${element1} and ${element2}`);
```
  1. The selected elements are: Gold and Argon
  2. The selected elements are: Aluminium and Silver
  3. The selected elements are: Argon and Neon
  4. The selected elements are: Gold and Neon
  5. The selected elements are: Argon and Gold
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 42MSQ3 marksselect all that apply
Given the following parent-child setup in Vue 2: question figure and inside the child: question figure Which statements are correct?
Text of the picture (copyable)
```html
<child-box :message="parentMsg" @reply="handleReply"></child-box>
```
```javascript
this.$emit('reply', 'ok')
```
  1. flows from parent to child through props.
    text
    message
  2. is a custom event sent from child to parent.
    text
    reply
  3. The child should directly change to update the parent source of truth.
    text
    message
  4. If changes in the parent, the child can receive the updated prop value.
    text
    parentMsg
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 43MSQ3 marksselect all that apply
Identify the issue in the following Vue.js code: question figure Why does the value not update correctly when the button is clicked?
Text of the picture (copyable)
```html
<div id="app">
  <p>{{ message }}</p>
  <button @click="changeMessage">Click</button>
</div>

<script>
  new Vue({
    el: '#app',
    data: {
      message: "Hello"
    },
    methods: {
      changeMessage: () => {
        this.message = "Updated"
      }
    }
  })
</script>
```
message
  1. should be used instead of
    text
    v-on
    ```
    @click
    ```
  2. Arrow functions do not bind their own
    text
    this
  3. should be a function in all Vue instances
    text
    data
  4. Vue.js does not support external methods
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 44MSQ3 marksselect all that apply
Consider the following JavaScript code snippet. question figure Which of the following statements is/are correct?
Text of the picture (copyable)
```javascript
class MathUtils {
  static add(a, b) {
    return a + b;
  }
  multiply(a, b) {
    return a * b;
  }
}

const utils = new MathUtils();
```
  1. will work correctly and return 8
    text
    ```
    MathUtils.add(5, 3)
    ```
  2. will work correctly and return 8
    text
    ```
    utils.add(5, 3)
    ```
  3. will work correctly and return 15
    text
    ```
    utils.multiply(5, 3)
    ```
  4. will work correctly and return 15
    text
    ```
    MathUtils.multiply(5, 3)
    ```
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 45MCQ4.5 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
var var1 = 25;
var var2 = 35;

const obj = {
    var1: 45,
    var2: 55,
    func1: function(){
        console.log(`You are accessing: ${var1}`)
    },
    func2: () => {
        console.log(`You are accessing: ${this.var2}`)
    },
}

obj.func1()
obj.func2()
```
  1. You are accessing: 45 You are accessing: 55
  2. You are accessing: 25 You are accessing: 35
  3. You are accessing: 25 You are accessing: 55
  4. You are accessing: 45 You are accessing: 35
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 46MCQ4.5 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console in correct order?
Text of the picture (copyable)
```javascript
console.log(z);
var a = "alpha";
console.log(a);
let b = "beta"
console.log(b);
d();
console.log(c);
const c = "charlie"
function d(){
    console.log("delta")
}
var z = function(){
    console.log("zeta")
}
```
  1. undefined alpha beta delta Reference Error
  2. zeta undefined beta delta Reference Error
  3. undefined Reference Error beta charlie undefined
  4. zeta Reference Error beta charlie undefined
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 47MCQ4.5 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
let myArr = ["January", "March", "April", "August", "September", "October"]

let modArr = myArr.map((m) => m.slice(2)).
    filter((m) => m.length < 5).
    sort();

console.log(modArr[1]);
```
  1. ['gust', 'rch', 'ril']
  2. ['rch', 'ril', 'gust']
  3. ril
  4. rch
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 48MCQ4.5 marks
Consider the following JavaScript code snippet. question figure What will be the output of the above code on the browsers’ console?
Text of the picture (copyable)
```javascript
function first() {
  console.log("First start");
  setTimeout(function () {
    console.log("First timeout");
  }, 0);
  console.log("First end");
}

function second() {
  console.log("Second start");
  setTimeout(function () {
    console.log("Second timeout");
  }, 0);
}

console.log("Program start");
first();
second();
console.log("Program end");
```
  1. Program start First start First timeout First end Second start Second timeout Program end
  2. Program start First start First end First timeout Second start Second timeout Program end
  3. Program start First timeout First start First end Second timeout Second start Program end
  4. Program start First start First end Second start Program end First timeout Second timeout
MAD2 End Term · 10 May 2026 · open the full paper
Practice 49MCQ2 marks
Which of the following statements is true regarding the "this" keyword in JavaScript?
  1. "this" in an arrow function refers to the global object.
  2. "this" inside a regular function refers to the object that owns the function.
  3. Arrow functions do not have their own "this" and inherit it from the surrounding scope.
  4. "this" always points to the window object in browser environments.
MAD2 End Term · 10 May 2026 · open the full paper
Practice 50MCQ2 marks
Consider the below JavaScript program. question figure What will be the output of the above program?
Text of the picture (copyable)
```javascript
let arr = [1, 2, 3];
let sum = arr.reduce((acc, val, idx, array) => acc + val, 0);
console.log(sum);
```
  1. 0
  2. 3
  3. 6
  4. 9
  5. 12
MAD2 End Term · 10 May 2026 · open the full paper
Practice 51MCQ2 marks
You are building a cricket analytics app. The file battingStats.js contains the following exports: question figure In another file app.js, which of the following import statements will correctly import both strikeRate and playerName ? ( Assume both files are in the same directory )
Text of the picture (copyable)
```javascript
export const strikeRate = (runs, balls) => {
  return (runs / balls) * 100;
};

export const playerName = "Virat Kohli";
```
  1. text
    ```javascript
    import strikeRate, playerName from "./battingStats.js";
    ```
  2. text
    ```javascript
    import { strikeRate, playerName } from "./battingStats.js";
    ```
  3. text
    ```javascript
    import * as stats from "./battingStats.js";
    ```
  4. text
    ```javascript
    require("./battingStats.js");
    ```
MAD2 End Term · 10 May 2026 · open the full paper
Practice 52MCQ3 marks
Consider the below JavaScript program. question figure What will be the output of the above program?
Text of the picture (copyable)
```javascript
const promise = new Promise((resolve, reject) => {
  resolve('Success!');
  reject('Error!');
});

promise.then(console.log).catch(console.log);
```
  1. Success!
  2. Error!
  3. Success! Error!
  4. Error! Success!
MAD2 End Term · 10 May 2026 · open the full paper
Practice 53MCQ3 marks
Consider the below Vuex store configuration: question figure If the addItemAsync action is dispatched with the item 'React', what will be the state of items after 2 seconds?
Text of the picture (copyable)
```javascript
const store = new Vuex.Store({
  state: {
    items: ['Angular', 'Vue'],
  },
  mutations: {
    addItem(state, item) {
      state.items.push(item);
    },
  },

  actions: {
    addItemAsync({ commit }, item) {
      setTimeout(() => {
        commit('addItem', item);
      }, 500);
    },
  },
});
```
  1. ['Angular', 'Vue']
  2. ['Angular', 'Vue', 'React']
  3. ['React']
  4. ['Angular']
MAD2 End Term · 10 May 2026 · open the full paper
Practice 54MCQ3 marks
Consider the below Vue app. question figure What happens when the user navigates to an undefined route like "/random"?
Text of the picture (copyable)
```html
<div id="app">
  <router-link to="/about">Go to About</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: '/about' }
  ];

  const router = new VueRouter({ routes });

  new Vue({
    el: '#app',
    router
  });
</script>
```
  1. Browser navigates to /random and shows a blank page.
  2. Browser navigates to /random but renders nothing.
  3. Browser redirects to /about and displays "About".
  4. Error: No matching route.
MAD2 End Term · 10 May 2026 · open the full paper
Practice 55MCQ3 marks
What will be the output of the following JavaScript code? question figure
Text of the picture (copyable)
```javascript
console.log(typeof NaN);
console.log(typeof null);
console.log(NaN == null);
console.log(NaN === null);
```
  1. number, object, false, false
  2. NaN, null, true, true
  3. number, object, true, false
  4. NaN, null, false, false
MAD2 End Term · 10 May 2026 · open the full paper
Practice 56MCQ3 marks
Consider the following JavaScript program: question figure What will be the output of the above program on a browser's console?
Text of the picture (copyable)
```javascript
class Animal {
  constructor(type) {
    this.type = type;
  }
  speak() {
    console.log(`${this.type} makes a sound`);
  }
  getType() {
    return `This is a ${this.type}`;
  }
}

class Dog extends Animal {
  constructor(type, breed) {
    super(type);
    this.breed = breed;
  }
  speak() {
    console.log(`${this.type} ${this.breed} barks`);
  }
}

const myDog = new Dog('Dog', 'Labrador');
myDog.speak();
console.log(myDog.getType());
console.log(myDog instanceof Dog);
console.log(myDog instanceof Animal);
console.log(Dog.prototype.__proto__ === Animal.prototype);
```
  1. question figure
    text
    ```
    Dog Labrador barks
    This is a Dog
    true
    true
    true
    ```
  2. question figure
    text
    ```
    Dog makes a sound
    This is a Dog Labrador
    true
    false
    true
    ```
  3. question figure
    text
    ```
    Dog Labrador barks
    This is a Dog Labrador
    true
    true
    false
    ```
  4. question figure
    text
    ```
    Dog Labrador barks
    This is a Dog
    false
    true
    true
    ```
MAD2 End Term · 10 May 2026 · open the full paper
Practice 57MCQ3 marks
Consider the following JavaScript program: question figure What will be the output of the above program?
Text of the picture (copyable)
```javascript
const person = {
  firstName: 'John',
  lastName: 'Doe',
  age: 30,
  city: 'New York'
};

const { firstName, city, ...rest } = person;
const newPerson = { firstName, location: city, ...rest };

console.log(firstName);
console.log(rest);
console.log(newPerson);
```
  1. question figure
    text
    ```
    John
    { city: 'New York', lastName: 'Doe', age: 30 }
    { firstName: 'John', location: 'New York', city: 'New York', lastName:
    'Doe', age: 30 }
    ```
  2. question figure
    text
    ```
    John
    { 'lastName': 'Doe', 'age': 30 }
    { 'firstName': 'John', 'location': 'New York', 'lastName': 'Doe', 'age': 30 }
    ```
  3. question figure
    text
    ```
    John
    { 'lastName': 'Doe', 'age': 30 }
    { 'firstName': 'John', 'location': 'New York', 'city': 'New York', 'lastName':
    'Doe', 'age': 30 }
    ```
  4. question figure
    text
    ```
    undefined
    { firstName: 'John', city: 'New York', lastName: 'Doe', age: 30 }
    { firstName: 'John', location: 'New York' }
    ```
MAD2 End Term · 10 May 2026 · open the full paper
Practice 58MCQ3 marks
Consider the following JavaScript program: question figure What will be printed in the console when the above code is executed?
Text of the picture (copyable)
```javascript
const CAPACITY = 75;
const TOTAL_PEOPLE = 213;

function allocatePeople() {
  return new Promise((resolve, reject) => {
    let slots = [0, 0, 0];
    let remaining = TOTAL_PEOPLE;

    for (let i = 0; i < slots.length; i++) {
      if (remaining >= CAPACITY) {
        slots[i] = CAPACITY;
        remaining -= CAPACITY;
      } else {
        slots[i] = remaining;
        remaining = 0;
      }
    }

    reject(slots);
  });
}

async function startAllocation() {
  try {
    const result = await allocatePeople();
    console.log("Passed " + JSON.stringify(result));
  } catch (error) {
    console.log("Failed " + JSON.stringify(error));
  }
}

startAllocation();
```
  1. Passed [75,75,63]
  2. Failed [0,0,0]
  3. Failed [75,75,63]
  4. Passed [0,0,0]
MAD2 End Term · 10 May 2026 · open the full paper
Practice 59MCQ3 marks
Match the Vue directive in Directive with its correct functionality in Description using Vue.js. question figure
Text of the picture (copyable)
| Directive | Description |
|---|---|
| 1. v-if | A. Two-way data binding between input and data |
| 2. v-for | B. Conditionally renders elements in the DOM |
| 3. v-bind | C. Binds HTML attributes dynamically |
| 4. v-model | D. Renders a list of items |
  1. 1–A, 2–D, 3–C, 4–B
  2. 1–D, 2–B, 3–C, 4–A
  3. 1–B, 2–C, 3–D, 4–A
  4. 1–B, 2–D, 3–C, 4–A
MAD2 End Term · 10 May 2026 · open the full paper
Practice 60MCQ4.5 marks
Consider the following Vue application with markup index.html and JavaScript file app.js. question figure Suppose the application is running on http://127.0.0.1:8080. What will be rendered by the browser?
Text of the picture (copyable)
File: index.html

```html
<div id="app"></div>
<script src="script.js"></script>
```

File: script.js

```javascript
new Vue({
  el: '#app',
  template: `<div>
    Status: {{status}}<br>
    Value: {{value}}
  </div>`,
  data: {
    status: "Initial",
    value: 10,
  },
  beforeCreate() {
    this.status = this.status + " -> Created"
    this.value = this.value + 5
  },
  beforeMount() {
    this.status = this.status + " -> Ready"
    this.value = this.value - 2
  },
  created() {
    this.status = this.status + " -> Mounted"
    this.value = this.value * 2
  },
  mounted() {
    this.status = this.status + " -> Done"
    this.value = this.value / 2
  },
})
```
  1. Status: Initial -> Created -> Ready -> Mounted -> Done Value: 13
  2. Status: Initial -> Ready -> Mounted -> Done Value: 8
  3. Status: Initial -> Created -> Mounted -> Ready -> Done Value: 14
  4. Status: Initial -> Mounted -> Ready -> Done Value: 9