MAD Study Hub

Home / Past papers / MAD2 End Term / this paper

IIT M DIPLOMA FN1 EXAM ETD1 11 Dec 2022 - 11 Dec 2022

MAD2 End Term32 questions100 marks24 MCQ · 8 MSQDiploma
Elapsed 00:00
Q1MCQ2 marks
question figure
Text of the picture (copyable)
Consider the below Vue component and Vuex store definition.

```javascript
const store = new Vuex.Store({
  state: {
    stateA: 10,
    stateB: 20,
    stateC: 30,
  }
})

Vue.component('Vuex-demo', {
  template: `
    <div>
      state A : {{stateA}}
      state B : {{stateB}}
      state C : {{stateC}}
    </div>
  `,
  computed: code
})
```

Which of the following is the best suitable definition of the "code" placeholder in the above app (assuming the store is binded with the Vue app, and the mapState is imported appropriately)?
  1. …mapState(['state_1', 'state_2', 'state_3'])
  2. mapState(['state_1', 'state_2', 'state_3'])
  3. Both …mapState(['state_1', 'state_2', 'state_3']) and mapState(['state_1','state_2', 'state_3'])
  4. A Vue component cannot access Vuex store state.
Q2MCQ2 marks
Suppose you are writing an application to be used by lakhs of people, which will run a brute force algorithm and gives back the result to the user of the application when ready. Considering this context, arrange the below set of actions/operations to achieve a desirable and practical design. I. Invoke the webhook II. Relieve the worker III. Dispatch a backend job
  1. I, III, II
  2. III, I, II
  3. I, II, III
  4. The polling will be a better design.
Q3MCQ2 marks
Which of the following statements is true?
  1. The CSRF protection is enforced by the flask framework, by default.
  2. The data stored in local storage is synchronized across the devices for a givenuser.
  3. A flask application returns CORS headers for cross domain javascript requests,by default.
  4. None of these
Q4MCQ2 marks
Suppose you want to store some data on the client, which has to be sent back to the server with every subsequent request. Which of the following is the most suited for this purpose?
  1. Local Storage
  2. Session Storage
  3. Cookie
  4. Any of these can be used
Q5MCQ2 marks
question figure
Text of the picture (copyable)
Suppose an application is being loaded from the origin http://origin1.com. Which of the following origins the browser will allow while making a fetch call, by default?
  1. question figure
    text
    http://origin2.com
  2. question figure
    text
    http://api.origin2.com
  3. question figure
    text
    http://origin1.com/api/
  4. question figure
    text
    All of these
Q6MCQ2 marks
Which of the following is true regarding session cookies?
  1. They get deleted once the user closes the browser’s window.
  2. They will be sent to the origin server with each request, by default.
  3. They will not be sent to the origin server with each request, by default.
  4. All of these.
Q7MCQ3 marks
question figure
Text of the picture (copyable)
Which of the following shows the correct output, if the below program is executed?

```javascript
for (var i=1; i<4; i+=2)
    setTimeout(() => console.log(i), 0)
```
  1. 13
  2. 123
  3. 55
  4. 555
Q8MCQ3 marks
question figure
Text of the picture (copyable)
Suppose a particular user of an application hosted on http://example1.com has
delete privilege and URL to delete resource with ID 1 is 'http://example1.com/delete?id=1'.
The user visits a malicious website having an image link with definition
```html
"<img src='http://example1.com/delete?id=1' />",
```
and the user clicks on the link, which
in turn leads to the deletion of the resource without the knowledge of the user.

Which of the following correctly describes the above scenario?
  1. Cross Site Scripting
  2. Cross Site Request Forgery
  3. Session Hijacking
  4. None of these
Q9MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following javascript program. What will be logged on to console after executing the program?

```javascript
const promiseFactory = (data) => {
  return new Promise(((resolve) => {
    resolve(data)
  }))
}

result = []
p1 = promiseFactory('Hello')
p1.then((data) => {
  result.push(data)
  return promiseFactory('World')
}).then((data) => {
  result.push(data)
})

console.log(result)
```
  1. []
  2. [‘Hello’, ‘World’]
  3. [‘World’, ‘Hello’]
  4. [‘Hello’]
Q10MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following javascript code. What will be logged on the console after executing this program?

```javascript
const Person = function (name, city, pinCode) {
  this.name = name
  this.city = city
  this.pin = pinCode
}

Person.prototype.getAddress = function () {
  return `Name: ${this.name}, City: ${this.city}, ${this.pin}`
}

per1 = new Person('Rohit', 'Mumbai', '277403')
console.log(per1.getAddress())
```
  1. Name: , City: , Pin:
  2. Name: Rohit, City: Mumbai, Pin: 277403
  3. Name: Rohit, City: Mumbai, 277403
  4. None of these
Q11MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following javascript program. What will be logged on to console after executing this program?

```javascript
const promiseFactory = (isShopOpen) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if (isShopOpen) {
        resolve('Making Coffee')
      } else {
        reject('Making Tea')
      }
    }, 1000)
  })
}

const bringTea = promiseFactory(true)
bringTea
  .then((data) => {
    console.log(data)
  })
  .catch((data) => {
    console.log(data)
  })
console.log('Boiling Water ....')
```
  1. Boiling Water ….
  2. Boiling Water ….Making Coffee
  3. Boiling Water ….Making Tea
  4. Making CoffeeBoiling Water ….
Q12MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following Vue application with markup "index.html" and javascript file "app.js".

index.html:

```html
<head>
  <style>
    .booked {
      background-color: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <button :class="{booked:seat.isBooked}" v-for="seat in seats">
      {{seat.seatNo}}
    </button>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script src="app.js"></script>
</body>
```

app.js:

```javascript
new Vue({
  el: '#app',
  data: {
    seats: [
      { seatNo: 1, isBooked: false },
      { seatNo: 2, isBooked: true },
      { seatNo: 3, isBooked: true },
    ],
  },
})
```

Suppose the application is running on 'http://localhost:8080'. What will be the background colour of seat with seatNo 1 and 2, respectively, when the user visits the home page of the application (Assume the default background colour of button to be white)?
  1. Red, Red
  2. Red, White
  3. White, White
  4. White, Red
Q13MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below javascript program, and predict the output, if executed. Also, what will be the minimum time taken by the program to execute?

```javascript
exams = ['quiz1', 'quiz2', 'enterm']

new Promise((rej, res) => {
    let count = 2
    let a = setInterval(() => {
        count += 3;
        exams.pop();
        if (count % 2) {
            exams.push('endterm')
        }
        else if (count % 7 == 0) {
            clearInterval(a);
            rej();
        }
    }, 2000)
}).then(d => console.log("Rejected", exams))
  .catch(e => console.log("Resolved", exams))
```
  1. Rejected [‘quiz1]Minimum Time taken: 10 seconds
  2. Rejected [‘quiz1]Minimum Time taken: 8 seconds
  3. Resolved [‘quiz1]Minimum Time taken: 8 seconds
  4. Resolved [‘quiz1]Minimum Time taken: 10 seconds
Q14MCQ4.5 marks
Suppose you open “index.html” file in a browser, and type the text “EndTermExam” in the text box shown (after removing the previous text, if any), and hard refresh the page thrice, without clicking anywhere. What will be the value shown in the text box, and the “marks” placeholder, respectively? question figure
Text of the picture (copyable)
Consider the following Vue application with markup "index.html" and javascript file "app.js".

index.html:

```html
<div id = "app">
    <input v-model = "subject" @change = "compute_marks">
    <p> {{marks}} </p>
</div>
<script scr = "app.js"></script>
```

app.js:

```javascript
new Vue({
    el : "#app",
    data : {
        subject : "AppDev",
        marks : 50,
    },

    mounted () {
        this.subject = "AppDev";
        this.marks = 50;

        if (localStorage.marks) {
            this.subject += "2";
            this.marks = localStorage.marks + 20;
        }
        else {
            this.subject += "1";
            this.marks += 20;
        }
    },
    methods : {
        compute_marks() {
            localStorage.setItem("subject", this.subject);
            localStorage.setItem("marks", this.marks + 10);
        }
    }
})
```
  1. AppDev1, 80
  2. AppDev2, 80
  3. AppDev1, 70
  4. AppDev2, 70
Q15MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue application with markup "index.html" and javascript file "app.js".

index.html:

```html
<body>
    <div id="app">
        <h4 id="total">Total Run: {{total}}</h4>
        <h4 id="player">{{Player.name}}: {{Player.run}}</h4>
        <button @click="extra=true">Extra</button>
        <button @click="addRuns(4)">Run</button>
    </div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
    <script src="app.js"></script>
</body>
```

app.js:

```javascript
new Vue({
    el: '#app',
    data: {
        extra: false,
        total: 20,
        Player: { name: 'M.S. Dhoni', run: 10 }
    },

    methods: {
        addRuns(run) {
            if (this.extra === true) {
                this.Player.run += run
            }
            this.total += run
            this.extra = false
        },
    },
})
```

Suppose the application is running on 'http://localhost:8080'. If the user clicks on the button with the text "Extra", and then clicks on the button with the text "Run" twice. What will be rendered inside the element with ID "total" and "player", respectively?
  1. Total Run: 24, M.S. Dhoni: 14
  2. Total Run: 28, M.S. Dhoni: 14
  3. Total Run: 24, M.S. Dhoni: 18
  4. Total Run: 28, M.S. Dhoni: 18
Q16MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following javascript program, and predict the output if executed.

```javascript
new Promise((arg1, arg2) => {
  if (5 === "5") arg1(5)
  else arg2(5)
}).
then(d => {
  console.log("Checkpoint 3", d);
  throw new Error(20);
  return d * 5;
}).
then(d => {
  console.log("Checkpoint 1", d);
  return d;
}).
catch(e => {
  console.log("Checkpoint 4", e + 6);
  return e * 5;
}).finally(d => {
  console.log("Checkpoint 6", d);
  return d * 5;
}).then(d => {
  console.log("Checkpoint 2", d);
  return d * 5;
})
```
  1. Checkpoint 4 11Checkpoint 6 undefinedCheckpoint 2 25
  2. Checkpoint 4 11Checkpoint 6 25Checkpoint 2 125
  3. Checkpoint 3 5Checkpoint 4 ErrorCheckpoint 6 undefinedCheckpoint 2 NaN
  4. Checkpoint 3 5Checkpoint 4 ErrorCheckpoint 6 NaNCheckpoint 2 NaN
Q17MSQ2 marksselect all that apply
Which of the following statement(s) is/are true in the context of point-to-point communication and message broker?
  1. In point-to-point communication, the number of connections grow with theorder of O(nlogn).
  2. If a central message broker is used, the number of connections grow with theorder of O(logn).
  3. If a central message broker is used, the number of connections grow with theorder of O(n).
  4. A message broker makes the network more scalable, if compared with point-to-point communication.
Q18MSQ2 marksselect all that apply
Which of the following statement(s) is/are true regarding caching?
  1. A shared cache is generally suitable for storing the personalized responses.
  2. A private cache is usually tied to a specific client.
  3. The caching helps in improving the performance of a web application.
  4. All of these
Q19MSQ3 marksselect all that apply
Which of the following statement(s) is/are true regarding javascript language?
  1. JavaScript is a high level programming language.
  2. JavaScript moves the declaration of all the arrow functions to the top of theirscope.
  3. The language does not allow the global declaration of user defined functions.
  4. A function can be invoked inside another function in the language.
Q20MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the below Vue class binding and select the most appropriate option(s).

```html
<div v-bind:class="[isClassA ? classA : '', classB]"></div>
```
  1. The classes, namely “classA” and “classB” will always be applied to the divelement.
  2. The class, namely “classB” will always be applied to the div element.
  3. The class, namely “classA” will only be applied to the div element, if the variable“isClassA” evaluates to true.
  4. The class, namely “classB” will only be applied to the div element, if no variablewith name “isClassA” exists.
Q21MSQ3 marksselect all that apply
If an application is entirely built on the client end using javascript (without a database). Which of the following statements is/are false?
  1. All the progress will always be lost on the force reload of the page.
  2. All the progress may not necessarily be lost on the force reload of the page.
  3. The application will not allow force reload of the page.
  4. The progress made in a machine can be accessed on another machine.
Q22MSQ3 marksselect all that apply
Which of the following statement(s) is/are false in the context of scaling a web application?
  1. Scaling out is always a preferred choice when the network traffic is growing.
  2. The horizontal scaling will typically clone the application as many times asrequired, and add a load balancer to maintain uniform traffic across the servers.
  3. The horizontal partitioning splits a given table into multiple tables, with eachtable having the same structure.
  4. The diagonal scaling refers to cloning the application first, and then scaling upthe different servers to meet the requirements.
Q23MSQ3 marksselect all that apply
Which of the following statement(s) is/are false?
  1. A flask application runs in a threaded mode by default.
  2. A fetch API call always returns a promise.
  3. The promise returned by fetch API resolves to an HTTP response status 500,with the “ok” property of the response set to true.
  4. A headless CMS aims to manage both the content and frontend via APIs.
Q24MSQ4.5 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the following javascript program, and predict the output, if executed as a script.

```javascript
var a = 39
const obj1 = {
    'a' : 50,
    'func' : function () {
        let in_func = () => console.log("This :", this.a, ", Normal :", a)
        in_func();
    }
}

const obj2 = {
    'a' : 60,
    'func' : function () {
        let in_func = () => console.log("This :", this.a, ", Normal :", a)
        in_func();
    }
}

obj1.func.call()
```
  1. This : 39 , Normal : 39
  2. This : undefined , Normal : 39
  3. This : undefined , Normal : 50
  4. This : 39 , Normal : 50
Comprehension passage - the questions below it refer to this
question figure
Q25MCQ3 marks
question figure
Text of the picture (copyable)
Suppose the application is running on 'http://localhost:8080'. What will be rendered by the browser inside the div element with ID 'slot-detail', when the user visits the website home page for the first time (except the button)?
  1. Slot ID: 1, Slot Status: Booked
  2. Slot ID: 1, Slot Status: Not Booked
  3. Slot ID: 1
  4. Slot Status: Booked
Q26MCQ3 marks
Suppose the application is running on ‘http://localhost:8080'. What will be rendered by the browser inside the div element with ID ‘slot-detail’, when user clicks on the button with the text ‘Book’ 3 times (except the button)?”
  1. Slot ID: 1, Slot Status: Booked
  2. Slot ID: 1, Slot Status: Not Booked
  3. Slot ID: 1
  4. Slot Status: Booked
Comprehension passage - the questions below it refer to this
Based on the above data, answer the given subquestions. question figure
Q27MCQ3 marks
question figure
Text of the picture (copyable)
Suppose the application is running on
‘http://localhost:8080’. What will be
rendered inside the ‘router-view’ of
Booking component when user visits
the URL ‘http://127.0.0.1:8080/#/'?
  1. Page not Found
  2. Booked Slots
  3. Unbooked Slots
  4. None of these
Q28MCQ3 marks
question figure
Text of the picture (copyable)
What will be rendered inside the
'router-view' of Booking component
when user visits the URL
'http://127.0.0.1:8080/#/booked'?
  1. Page not Found
  2. Booked Slots
  3. Unbooked Slots
  4. None of these
Comprehension passage - the questions below it refer to this
question figure
Q29MCQ4.5 marks
question figure
Text of the picture (copyable)
Suppose the application is running on
'http://localhost:8080', and a user visits
the same URL. What will be rendered
inside the div element having ID 'sort'?
  1. 1917
  2. 19
  3. 17
  4. 1719
Q30MCQ3 marks
question figure
Text of the picture (copyable)
Suppose the application is running on
'http://localhost:8080', and a user visits
the same URL. What will be rendered
inside the div element having ID "status"?
  1. 12
  2. 1
  3. 2
  4. None of these
Comprehension passage - the questions below it refer to this
question figure
Q31MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the application is running on 'http://localhost:8080'. Suppose the user visits the URL 'http://127.0.0.1:8080/#/slot/true'. What will be rendered by the browser inside the "router-view"?
  1. 1. Slot12. Slot2
  2. 1. Slot22. Slot3
  3. 1. Slot1
  4. 1. Slot2
Q32MCQ4.5 marks
question figure
Text of the picture (copyable)
Suppose the user visits the URL
'http://127.0.0.1:8080/#/slot/true?offset=1',
what will be rendered inside the
'router-view'?
  1. 1. Slot12. Slot2
  2. 1. Slot22. Slot3
  3. 1. Slot1
  4. 1. Slot2

Answer key

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

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, principles, and equations essential for the "Modern Application Development 2" exam, along with a Mermaid knowledge graph to visualize relationships.



Core Topics & Concepts Summary

1. Vue.js & Vuex

2. JavaScript (ES6+)

3. Web Security

4. Client-Side Storage

MechanismPersistenceScopeSent to ServerUse Case
CookiesConfigurableDomain-wideYesSession management, tracking.
Local StoragePersistentOriginNoOffline data, user preferences.
Session StorageSession-onlyTab-specificNoTemporary data (e.g., form drafts).

5. Backend & Scalability

6. Caching

Cache TypeScopeUse Case
Private CacheClient-specificPersonalized data (e.g., user sessions).
Shared CacheShared across usersStatic assets (e.g., images, CSS).

7. REST & APIs

8. Modern JavaScript Frameworks

9. Design Patterns



Key Equations & Code Snippets

1. Vuex mapState

computed: {
  ...mapState(['stateA', 'stateB']) // Maps stateA and stateB to computed properties.
}

2. Promise Chaining

promiseFactory(data)
  .then(result => {
    console.log(result);
    return anotherPromise();
  })
  .catch(error => console.error(error));

3. Async/Await

async function fetchData() {
  try {
    const data = await apiCall();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

4. Vue Class Binding

<div :class="{ active: isActive, 'text-danger': hasError }"></div>

5. Fetch API

fetch('https://api.example.com/data')
  .then(response => {
    if (!response.ok) throw new Error('Network error');
    return response.json();
  })
  .then(data => console.log(data))
  .catch(error => console.error(error));

6. Vue Router Dynamic Routes

const router = new VueRouter({
  routes: [
    { path: '/user/:id', component: User, props: true }
  ]
});

7. Event Loop Example

console.log('Start');
setTimeout(() => console.log('Timeout'), 0);
Promise.resolve().then(() => console.log('Promise'));
console.log('End');
// Output: Start → End → Promise → Timeout

8. CSRF Protection (Flask)

from flask_wtf.csrf import CSRFProtect
app = Flask(__name__)
csrf = CSRFProtect(app)

9. CORS in Flask

from flask_cors import CORS
app = Flask(__name__)
CORS(app)  # Enable CORS for all routes

10. Local Storage

localStorage.setItem('key', 'value');
const data = localStorage.getItem('key');