MAD Study Hub

Home / Past papers / MAD2 End Term / this paper

IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023 - 30 Apr 2023

MAD2 End Term32 questions100 marks22 MCQ · 10 MSQDiploma / QPD1
Elapsed 00:00
Q1MSQ2 marksselect all that apply
Which of the following statement(s) is/are false regarding javascript language?
  1. Hoisting moves the declaration of arrow functions to the top of their scopes.
  2. All 3 keywords, i.e., “var”, “let” and “const” can be used to declare globalvariables.
  3. The functions are treated as first class citizens in the language.
  4. Node.js is an example of a javascript engine.
Q2MSQ2 marksselect all that apply
Which of the following statement(s) is/are true about cookies and CORS?
  1. A session cookie expires as soon as the browser is closed.
  2. The CORS mechanism reduces the chances of malicious actions by explicitlysaying which URLs can be the originators of data.
  3. A browser sandbox causes any browser based malware to directly affect theuser’s system.
  4. All of these
Q3MSQ2 marksselect all that apply
question figure
Text of the picture (copyable)
Suppose a script is downloaded from the origin 'http://example.com'. The script can not make a request to which of the following origins, assuming none of the origins allow cross-origin requests?
  1. question figure
    text
    http://example.com/profile
  2. question figure
    text
    http://new.example.com
  3. question figure
    text
    http://example.com
  4. question figure
    text
    http://new.example.com/profile
Q4MSQ2 marksselect all that apply
Which of the following statement(s) is/are false about pub/sub messaging?
  1. Publisher has to know about all the subscribers.
  2. Publisher does not have to know about the subscribers.
  3. Communication between publisher and subscribers is asynchronous.
  4. Communication between publishers and subscribers is synchronous.
Q5MSQ2 marksselect all that apply
Which of the following statement(s) is/are false?
  1. In short polling, the server does not respond until the data is available or therequest times out.
  2. In long polling, the server does not respond until the data is available or therequest times out.
  3. In short polling, the server responds immediately with or without data.
  4. In long polling, the server responds immediately with or without data.
Q6MCQ3 marks
Which of the following shows the correct output if the javascript program written below is executed? question figure Which of the following shows the correct output if the javascript program written below is executed?
Text of the picture (copyable)
```javascript
const a = [2, 5, 8, 11, 14, 17]
const b = a.map(element => element ** 2)
const c = b.filter(element => element % 2)
const d = c.find(element => element % 3 == 1)
console.log(d)
```
  1. [25, 121, 289]
  2. [25, 121]
  3. 25
  4. 25 121
Q7MCQ3 marks
Which of the following statements is true in the context of REST?
  1. Both the HTTP request methods, “GET” and “POST” are idempotent.
  2. In general, an HTTP “PUT” request is used to make incremental changes to anexisting resource.
  3. A “DELETE” request, that deletes a resource using a unique identifier, isidempotent.
  4. None of these
Q8MCQ3 marks
Which of the following shows the correct output if the javascript program written below is executed? question figure Which of the following shows the correct output if the javascript program written below is executed?
Text of the picture (copyable)
```javascript
async function demo () {
    let prom = new Promise((res, rej) => {
        setTimeout(() => res(40), 2000)
    })
    console.log("Statement 2") // Statement 2
    return prom
}

demo().then(result => console.log(result))
console.log("Statement 1") // Statement 1
```
  1. question figure
    text
    40
    Statement 2
    Statement 1
  2. question figure
    text
    40
    Statement 1
    Statement 2
  3. question figure
    text
    Statement 1
    Statement 2
    40
  4. question figure
    text
    Statement 2
    Statement 1
    40
Q9MCQ3 marks
Which of the following statements is false regarding a message broker?
  1. A message broker allows two servers in a network to directly communicatewith each other, without an intermediary.
  2. A message broker makes the network scalable for adding more servers to thenetwork.
  3. A message broker can be used for batch processing of messages.
  4. A message broker is well suited in case of traffic spikes, as messages areretained in the queue until processed.
Q10MCQ3 marks
Which of the following statement(s) is incorrect regarding the prototype in JavaScript?
  1. Every constructor function has a property named ‘prototype’.
  2. Any object created using the new keyword and the constructor function, willinherit from the constructor’s prototype object.
  3. Prototype of an object can be accessed using the ‘__proto__’ property of theobject.
  4. The prototype of an object can be accessed using the ‘prototype’ property ofthe object.
Q11MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”. Suppose the user clicks on buttons with text “3” and then “4”, what will be rendered inside the “Player” component?
Text of the picture (copyable)
```html
index.html:
<body>
    <div id="app"></div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="app.js" type="module"></script>
</body>

app.js:
const Player = {
    template: `<div><div>{{ striker.name }}</div>
    <div>{{ nonStriker.name }}</div>
    </div>`,
    data() {
        return {
            player1: { name: 'Rohit' },
            player2: { name: 'Virat' },
        }
    },
    props: {
        run: { type: Number, default: 0 },
    },
    computed: {
        striker() {
            return this.run % 2 == 0 ? this.player1 : this.player2
        },
        nonStriker() {
            return this.run % 2 == 1 ? this.player1 : this.player2
        },
    },
}

const Run = {
    template: `<button @click="$emit('run-changed',
    run)">{{ run }}</button>`,
    props: { run: Number },
}

new Vue({
    el: '#app',
    template: `<div>
        <Player :run='score'/>
        <div style='display: flex'>
            <Run :run="3" @run-changed = 'runChanged'/>
            <Run :run="4" @run-changed = 'runChanged' />
        </div>
    </div>`,
    components: { Run, Player },
    data: {
        score: 0,
    },
    methods: {
        runChanged(run) {
            this.score = run
        },
    },
})
```
  1. question figure
    text
    Rohit*
    Virat
  2. question figure
    text
    Virat*
    Rohit
  3. question figure
    text
    Virat*
    Rohit*
  4. question figure
    text
    Rohit*
    Virat*
Q12MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<div id="app"></div>
<script
  src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
  src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
```

app.js:
```javascript
const data = {
  1: { totalRun: 1000, totalMatches: 20 },
  2: { totalRun: 7000, totalMatches: 100 },
}
const NotFound = { template: '<div> Player Not Found</div>' }
const Profile = {
  template: `<div>Run: {{ {stat.totalRun}}, Matches:
{{stat.totalMatches}}, Average: {{average}}</div>`,
  data() {
    return {
      stat: data[this.$route.params.id],
    }
  },
  computed: {
    average() {
      return this.stat.totalRun / this.stat.totalMatches
    },
  },
}
const router = new VueRouter({
  routes: [
    { path: '/profile/:id', component: Profile },
    { path: '*', component: NotFound },
  ],
})
new Vue({
  el: '#app',
  template: '<div><router-view /></div>',
  router,
})
```

Suppose the application is running on "http://127.0.0.1:8080". What will be rendered inside the "router-view" component for the URL "http://127.0.0.1:8080/#/player"?
  1. Player Not Found
  2. Run: 1000, Matches: 20, Average: 50
  3. Run: 7000, Matches: 100, Average: 70
  4. None of these
Q13MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<div id="app"></div>
<script
  src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
  src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
```

app.js:
```javascript
const data = {
  1: { totalRun: 1000, totalMatches: 20 },
  2: { totalRun: 7000, totalMatches: 100 },
}

const NotFound = { template: '<div> Player Not Found</div>' }
const Profile = {
  template: `<div>Run: {{stat.totalRun}}, Matches:
{{stat.totalMatches}}, Average: {{average}}</div>`,
  data() {
    return {
      stat: data[this.$route.params.id],
    }
  },
  computed: {
    average() {
      return this.stat.totalRun / this.stat.totalMatches
    },
  },
}

const router = new VueRouter({
  routes: [
    { path: '/profile/:id', component: Profile },
    { path: '*', component: NotFound },
  ],
})

new Vue({
  el: '#app',
  template: '<div><router-view /></div>',
  router,
})
```

Suppose the application is running on "http://127.0.0.1:8080". What will be displayed for the URL "http://127.0.0.1:8080/#/profile/1"?
  1. Player Not Found
  2. Run: 1000, Matches: 20, Average: 50
  3. Run: 7000, Matches: 100, Average: 70
  4. None of these
Q14MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<body>
    <div id="app"></div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
    <script src="app.js" type="module"></script>
</body>
```

app.js:
```javascript
const overs = {
    1: [2, 3, 4, 6, 2],
    2: [3, 2, 5, 3, 1],
}

const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.</div>` }

const currentOver = {
    template: `<div style='display: flex'>
        <div v-for='run in over' style='padding: 10px'>{{run}}</div>
    </div>`,
    data() {
        return {
            over: overs[this.$route.params.overNo]
                ? overs[this.$route.params.overNo]
                : overs[2],
        }
    },
}

const liveScore = {
    template: `<div>Total Score:{{totalScore}} <router-view /></router-view></div>`,
    data() {
        return {
            totalScore: 100,
        }
    },
}

const router = new VueRouter({
    routes: [
        {
            path: '/live-score',
            component: liveScore,
            children: [
                { path: '', component: MatchNotStarted },
                { path: 'over/:overNo', component: currentOver },
            ],
        },
    ],
})

new Vue({
    el: '#app',
    template: `<div><router-view /></div>`,
    router,
})
```
Suppose the application is running on "http://127.0.0.1:8080". What will be rendered in the "router-view" component of the "live-score" component for URL "http://localhost:8080/#/live-score"?
  1. Total Score:100
  2. Match has not yet started.
  3. 2 3 4 6 2
  4. Over Not Found
Q15MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<body>
    <div id="app"></div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script
        src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
    <script src="app.js" type="module"></script>
</body>
```

app.js:
```javascript
const overs = {
    1: [2, 3, 4, 6, 2],
    2: [3, 2, 5, 3, 1],
}

const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.</div>` }

const currentOver = {
    template: `<div style='display: flex'>
<div v-for='run in over' style='padding: 10px'>{{run}}</div>
</div>`,
    data() {
        return {
            over: overs[this.$route.params.overNo]
                ? overs[this.$route.params.overNo]
                : overs[2],
        }
    },
}

const liveScore = {
    template: `<div>Total Score:{{totalScore}} <router-view /></router-view></div>`,
    data() {
        return {
            totalScore: 100,
        }
    },
}

const router = new VueRouter({
    routes: [
        {
            path: '/live-score',
            component: liveScore,
            children: [
                { path: '', component: MatchNotStarted },
                { path: 'over/:overNo', component: currentOver },
            ],
        },
    ],
})

new Vue({
    el: '#app',
    template: `<div><router-view /></div>`,
    router,
})
```

Suppose the application is running on "http://127.0.0.1:8080". What will be rendered in the "router-view" component of the "live-score" component for URL "http://localhost:8080/#/live-score/over/2"?
  1. Total Score:100
  2. Match has not yet started.
  3. 2 3 4 6 2
  4. 3 2 5 3 1
Q16MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<body>
    <div id="app"></div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
    <script src="app.js" type="module"></script>
</body>
```

app.js:
```javascript
const overs = {
    1: [2, 3, 4, 6, 2],
    2: [3, 2, 5, 3, 1],
}

const NotFound = { template: `<div> Over Not Found</div>` }
const MatchNotStarted = { template: `<div>Match has not yet started.</div>` }

const currentOver = {
    template: `<div style='display: flex'>
<div v-for='run in over' style='padding: 10px'>{{run}}</div>
</div>`,
    data() {
        return {
            over: overs[this.$route.params.overNo]
                ? overs[this.$route.params.overNo]
                : overs[2],
        }
    },
}

const liveScore = {
    template: `<div>Total Score:{{totalScore}} <router-view /></router-view></div>`,
    data() {
        return {
            totalScore: 100,
        }
    },
}

const router = new VueRouter({
    routes: [
        {
            path: '/live-score',
            component: liveScore,
            children: [
                { path: '', component: MatchNotStarted },
                { path: 'over/:overNo', component: currentOver },
            ],
        },
    ],
})

new Vue({
    el: '#app',
    template: `<div><router-view /></div>`,
    router,
})
```

Suppose the application is running on "http://127.0.0.1:8080". What will be rendered in the "router-view" component of the "live-score" component for URL "http://localhost:8080/#/live-score/over/20"?
  1. Total Score:100
  2. Match has not yet started.
  3. 2 3 4 6 2
  4. 3 2 5 3 1
Q17MSQ3 marksselect all that apply
Which of the following is/are not the correct ways to achieve the following. question figure Which of the following is/are not the correct ways to achieve the following.
Text of the picture (copyable)
1. Always apply class named "errorClass",
2. The class named "activeClass" should only be applied when the Vue data variable "isActive" is truthy
  1. question figure
    text
    ```html
    <div :class="[isActive ? 'activeClass' : '', 'errorClass']"></div>
    ```
  2. question figure
    text
    ```html
    <div :class="[{ 'activeClass' : isActive }, 'errorClass']"></div>
    ```
  3. question figure
    text
    ```html
    <div :class="[activeClass ? isActive : '', 'errorClass']"></div>
    ```
  4. question figure
    text
    ```html
    <div :class="[{ isActive : 'activeClass' }, 'errorClass']"></div>
    ```
Q18MSQ3 marksselect all that apply
Which of the following statement(s) is/are false regarding Vuex?
  1. A Vuex store provides a single source of truth that can drive the application.
  2. It provides a variable named “this.$vuexstore” to allow components to accessthe store data.
  3. A component cannot have its own local state, if the application uses Vuex.
  4. The mutations and actions are some constructs of a Vuex store.
Q19MSQ3 marksselect all that apply
Which of the following statement(s) is/are false regarding forward and reverse proxy?
  1. A forward proxy is used to protect the server(s) from the outside world.
  2. A reverse proxy can be used to cache the responses, to reuse them for similarsubsequent requests.
  3. A load balancer becomes irrelevant, where there is not more than 1 server.
  4. An efficient load balancer must use a round-robin algorithm.
Q20MSQ3 marksselect all that apply
Suppose you are building an application which requires sending emails to all the users stored in the database at regular intervals. Given below are the two approaches to satisfy the requirement. question figure Suppose you are building an application which requires sending emails to all the users stored in the database at regular intervals. Given below are the two approaches to satisfy the requirement. Choose the correct statement(s).
Text of the picture (copyable)
Approach 1:

```python
@celery.task
def send_bulk_emails():
    all_users = User.query.all() // Get all the user objects from the
    database
    for user in all_users:
        // send email to the user

send_bulk_emails.delay() // invokes celery task
```

Approach 2:

```python
@celery.task
def send_email(email):
    // send email to the user

all_users = User.query.all() // Get all the user objects from the database
for user in all_users:
    send_email.delay(user.email) // invokes celery task
```
  1. Approach 1 will take more time than approach 2, if more than 2 celery workersare available.
  2. Approach 2 will take more time than approach 1, if more than 2 celery workersare available.
  3. Both the approaches will take same time (approx), if only 1 celery worker isavailable.
  4. None of these
Q21MSQ3 marksselect all that apply
Which of the following statement(s) is/are correct regarding Vue.js framework?
  1. In Vue 2, the “el” property of the Vue constructor can be used to refer to anHTML element via an ID or a class.
  2. The components of Vue must define “data” property as a function.
  3. A Vue component cannot implement lifecycle hooks (i.e., created, mounted,etc.), if they are already implemented in the Vue instance.
  4. All of these
Q22MCQ2 marks
Which of the following statements is false about VueJS framework?
  1. VueJS is a framework built on top of HTML, CSS and javascript.
  2. VueJS is built on a component based architecture.
  3. It cannot be installed/used via npm (node package manager).
  4. All of these
Q23MCQ2 marks
Which of the following statements is false regarding webhooks?
  1. A webhook should deliver data to other apps, as it happens.
  2. A webhook is primarily meant for a server to server communication.
  3. A webhook typically uses an HTTP POST request to deliver the response.
  4. A webhook and web socket is essentially the same.
Q24MCQ2 marks
Suppose an endpoint in your flask application triggers a celery task, which generates a CSV file named “data.csv” and saves it in the static folder of a flask application. The file generator takes anywhere between 20 and 40 seconds to generate and save the CSV file. The below fetch call is used to get the file generated by the above explained celery task. question figure Suppose an endpoint in your flask application triggers a celery task, which generates a CSV file named “data.csv” and saves it in the static folder of a flask application. The file generator takes anywhere between 20 and 40 seconds to generate and save the CSV file. The below fetch call is used to get the file generated by the above explained celery task. Which of the following is the most efficient way to make the above fetch call so that it doesn’t fail and return the desired response?
Text of the picture (copyable)
```javascript
fetch("/static/data.csv").then(response => response.blob())
  .then(data => {
    // does something with the response data
  })
```
  1. Use short polling to check the state of the celery task after every 5 seconds,and make the fetch call, when the task succeeds.
  2. Use javascript function “setTimeout” to make the fetch after 41 seconds, whichmakes sure that the file is generated and saved to the desired location.
Q25MCQ4.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 the “index.html” file in a browser. What will be rendered by the browser?
Text of the picture (copyable)
index.html:

```html
<div id = "app">
  <my-comp>
    <template #header>
      This is header content
    </template>

    <template #footer>
      This is footer content
    </template>

    <p> This is some content </p>
  </my-comp>
</div>
<script src = "app.js"></script>
```

app.js:

```javascript
Vue.component("myComp", {
  template : `<div>
    <p>
      <slot name="header"></slot>
    </p>
    <p>
      <slot></slot>
    </p>
  </div>`,
})

const app = new Vue({
  el : "#app",
})
```
  1. question figure
    text
    This is header content
    This is footer content
    This is some content
  2. question figure
    text
    This is header content
    This is some content
  3. question figure
    text
    This is header content
  4. question figure
    text
    This is some content
    This is header content
Q26MCQ4.5 marks
Consider the following javascript program, and predict the output if executed. question figure Consider the following javascript program, and predict the output if executed.
Text of the picture (copyable)
```javascript
new Promise(((str1, str2) => {
    if (5 == "5") str1(5)
    else str2(8)
})).
then(d => {
    console.log("Checkpoint 4", d);
    throw new Error(20);
    return d * 5;
})
.then(d => {
    console.log("Checkpoint 2", d);
    return d;
}, d => {
    console.log("Checkpoint 1", d.message);
    return d.message * 2;
}).catch(e => {
    console.log("Checkpoint 3", e.message);
    return e.message * 2;
}).finally(d => {
    console.log("Checkpoint 6", d);
    return d * 5;
}).then(d => {
    console.log("Checkpoint 5", d);
    return d * 5;
})
```
  1. question figure
    text
    Checkpoint 4 5
    Checkpoint 3 20
    Checkpoint 1 undefined
    Checkpoint 6 NaN
  2. question figure
    text
    Checkpoint 4 8
    Checkpoint 1 20
    Checkpoint 6 NaN
    Checkpoint 5 40
  3. question figure
    text
    Checkpoint 4 5
    Checkpoint 1 20
    Checkpoint 6 undefined
    Checkpoint 5 40
  4. question figure
    text
    Checkpoint 4 5
    Checkpoint 5 20
    Checkpoint 1 40
    Checkpoint 6 200
Q27MCQ4.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 “abhishekabhinavabhi” 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 = "text" @input = "save_data">
    <p> {{content}} </p>
</div>
<script scr = "app.js"></script>
```

app.js:

```javascript
new Vue({
    el : "#app",
    data : {
        text : "",
        content : "",
    },

    mounted () {
        try {
            this.text = localStorage.getItem("value1").split("abhi").slice(1,
            -1).join("");
            this.content =
            localStorage.getItem("value1").split("abhi").slice(1).join("");
        }
        catch {
            this.text = "";
            this.content = "";
        }
    },

    methods : {
        save_data() {
            localStorage.setItem("value1", this.text);
            localStorage.setItem("value2", this.content);
        }
    }
})
```
  1. question figure
    text
    sheknav, sheknav
  2. question figure
    text
    nav, nav
  3. question figure
    text
    shek, sheknav
  4. question figure
    text
    ```
    "", nav
    ```
Q28MCQ4.5 marks
Which of the following shows the correct output if the javascript program written below is executed? question figure Which of the following shows the correct output if the javascript program written below is executed?
Text of the picture (copyable)
```javascript
let num = 50

const a = {
    num : 10,
    func : function (num) {
        console.log("Function A:", num)
    }
}

const b = {
    num : 20,
    func : function () {
        console.log("Function B:", this.num)
        a.func.bind(this)(num = 40)
    }
}

b.func.apply(a, [40])
```
  1. question figure
    text
    Function B: 20
    Function A: 10
  2. question figure
    text
    Function B: 40
    Function A: 40
  3. question figure
    text
    Function B: 10
    Function A: 10
  4. question figure
    text
    Function B: 10
    Function A: 40
Q29MCQ4.5 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”. Suppose you open the file “index.html” in a browser. What will be rendered by the browser?
Text of the picture (copyable)
index.html:
```html
<body>
    <div id="app"></div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="app.js" type="module"></script>
</body>
```

app.js:
```javascript
new Vue({
    el: '#app',
    template: `<div>
        <ol type='1'>
            <li v-for='fruit in fruits'>{{fruit}}</li>
        </ol>
    </div>`,
    data: {
        fruits: ['Banana', 'Mango'],
    },
    created() {
        this.fruits.push('Orange')
    },
    mounted() {
        this.fruits.push('Apple')
    },
})
```
  1. question figure
    text
    1) Banana
    2) Mango
  2. question figure
    text
    1) Banana
    2) Mango
    3) Orange
  3. question figure
    text
    1) Banana
    2) Mango
    3) Apple
  4. question figure
    text
    1) Banana
    2) Mango
    3) Orange
    4) Apple
Q30MCQ4.5 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”. Suppose you open the file “index.html” in a browser. What will be rendered inside the slot, by the browser?
Text of the picture (copyable)
index.html:
```html
<body>
    <div id="app"></div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="app.js" type="module"></script>
</body>
```

app.js:
```javascript
const Player = {
    template: `<div style='background-color:red'><slot></slot></div>`,
    data() {
        return {
            scores: [
                { name: 'Rohit', run: 20 },
                { name: 'Virat', run: 50 },
            ],
        }
    },
}

new Vue({
    el: '#app',
    template: `<div>
        <h1> Score Board</h1>
        <Player>
            <ol type='1'>
                <li v-for='score in scores'>{{score.name}}:
                    {{score.run}}</li>
            </ol>
        </Player>
    </div>`,
    data: {
        scores: [
            { name: 'Rohit', run: 50 },
            { name: 'Virat', run: 20 },
        ],
    },
    components: {
        Player,
    },
})
```
  1. question figure
    text
    1) Rohit: 20
    2) Virat: 50
  2. question figure
    text
    1) Rohit: 50
    2) Virat: 20
  3. question figure
    text
    1) Rohit: 50
    2) Virat: 50
  4. question figure
    text
    1) Rohit: 20
    2) Virat: 20
Q31MCQ4.5 marks
Consider the below flask application. question figure Consider the below 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_URL": 'redis://localhost:6379/1'
}

app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)

@cache.memoize(timeout=120)
def get_score(name):
    sleep(10)
    return 0

@app.route('/match/<int:match_id>/player/<name>/score')
def score(match_id, name):
    score = get_score(name)
    return f"IND Vs AUS- SKY: {score}"

if __name__ == '__main__':
    app.run(debug=True)
```

If the Redis server is running on "localhost:6379", and application is running on "http://127.0.0.1:5000". If a user visits the URL "http://127.0.0.1:5000/match/1/player/sky/score" at 7AM in the morning for the first time and then at 9AM for the second time. What will be the approximate absolute difference between the response time of the requests?
  1. 10 seconds
  2. 0 seconds
  3. 20 seconds
  4. 120 Seconds
Q32MCQ4.5 marks
Consider the below flask application. question figure Consider the below 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_URL": 'redis://localhost:6379/1'
}

app = Flask(__name__)
app.config.from_mapping(config)
cache = Cache(app)

@cache.memoize(timeout=120)
def get_score(name):
    sleep(10)
    return 0

@app.route('/match/<int:match_id>/player/<name>/score')
def score(match_id, name):
    score = get_score(name)
    return f"IND Vs AUS- SKY: {score}"

if __name__ == '__main__':
    app.run(debug=True)
```

If the Redis server is running on "localhost:6379", and application is running on "http://127.0.0.1:5000". If a user visits the URL "http://127.0.0.1:5000/match/1/player/sky/score" first and then "http://127.0.0.1:5000/match/2/player/sky/score" within 2 minutes. What will be the approximate absolute difference between the response time of the requests?
  1. 10 seconds
  2. 0 seconds
  3. 20 seconds
  4. 120 Seconds

Answer key

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

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 Mermaid knowledge graphs to visualize relationships.



1. JavaScript Core Concepts

Key Topics:

2. Web Technologies

Key Topics:

3. Pub/Sub Messaging

Key Topics:

4. Polling vs. Long Polling vs. WebSockets

Key Topics:

TechniqueDescriptionProsCons
Short PollingClient polls server at fixed intervals.Simple to implement.High latency, inefficient.
Long PollingServer holds request until data is available or timeout occurs.Lower latency than short polling.Complex to implement.
WebSocketsPersistent full-duplex connection between client and server.Real-time, low latency.Requires WebSocket support.

5. REST API

Key Topics:

6. Vue.js

Key Topics:

7. Proxies (Forward vs. Reverse)

Key Topics:

Proxy TypeDescriptionUse Cases
Forward ProxyActs on behalf of clients (hides client identities).Bypass restrictions, cache requests.
Reverse ProxyActs on behalf of servers (hides server identities).Load balancing, caching, security.

8. Celery (Task Queue)

Key Topics:

9. Flask & Caching

Key Topics:

10. Webhooks

Key Topics:

Summary of Equations (Math/Algorithms)

No mathematical equations were present in the questions, but here are key algorithmic concepts relevant to the exam:

  1. Array Operations (JavaScript):

    • map: Transforms each element.

      const b = a.map(x => x ** 2); // [4, 25, 64, ...]
    • filter: Returns elements matching a condition.

      const c = b.filter(x => x % 2); // Odd numbers
    • find: Returns the first element matching a condition.

      const d = c.find(x => x % 3 === 1); // First odd number ≡ 1 mod 3
  1. Asynchronous Flow:

    • Promise chaining:

      fetchData()
        .then(data => process(data))
        .catch(error => handle(error));
    • Async/await:

      async function fetch() {
        const data = await fetchData();
        console.log(data);
      }
  1. Vue.js Reactivity:

    • Computed properties:

      computed: {
        average() {
          return this.stat.totalRun / this.stat.totalMatches;
        }
      }


Exam Preparation Tips

  1. JavaScript:

    • Practice hoisting, this binding, and async/await.
    • Understand map/filter/find chaining.
  1. Vue.js:

    • Focus on component lifecycle, slots, Vue Router, and Vuex.
    • Practice dynamic class binding and computed properties.
  1. REST API:

    • Memorize HTTP methods and idempotency rules.
  1. Pub/Sub & Celery:

    • Understand decoupling and parallel task processing.
  1. Proxies & Caching:

    • Know the difference between forward/reverse proxies and caching strategies.
  1. Webhooks:

    • Compare with WebSockets and polling.
  1. Flask:

    • Review @cache.memoize and Redis integration.

Good luck! Let me know if you'd like deeper dives into any topic.