Home / Past papers / MAD2 End Term / this paper

THIS IS QUESTION PAPER FOR THE SUBJECT "DIPLOMA LEVEL: MODERN APPLICATION DEVELOPMENT 2" ARE YOU SURE YOU HAVE TO WRITE EXAM FOR THIS SUBJECT? CROSS CHECK YOUR HALL TICKET TO CONFIRM THE SUBJECTS TO BE WRITTEN. (IF IT IS NOT THE CORRECT SUBJECT, PLS CHECK THE SECTION AT THE TOP FOR THE SUBJECTS REGISTERED BY YOU)
Which of the following shows the correct output if the javascript program written below is executed? ```javascript const arr = [1, 2, 3, 4, 5, 6, 7, 8] const arr1 = arr.map(r => r**3) const arr2 = arr1.filter(r => ((r % 3 == 2) || (r % 4 == 3))) console.log(arr2) ```
Consider the following Vue application with markup “index.html” and javascript file “app.js”. Suppose you open “index.html” file in a browser, and type the text “IIT Madras” in the text box shown (after removing the previous text, if any), and hard refresh the page twice, without clicking anywhere. What will be the value shown in the text box, and the “age” placeholder, respectively?index.html:
```html
<div id = "app">
<input v-model = "name" @input = "do_something">
<p>{{age}}</p>
</div>
<script scr = "app.js"></script>
```
app.js:
```javascript
new Vue({
el : "#app",
data : {
name : "#app",
age : 0,
},
mounted () {
try {
this.name = localStorage.getItem("name").split(" ")[0];
this.age = localStorage.getItem("name").split(" ")[1];
}
catch {
this.name = "Default";
this.age = "Default";
}
},
methods : {
do_something() {
localStorage.setItem("name", this.name);
localStorage.setItem("age", this.age);
}
}
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be the color of text rendered inside the div with ID “run”, if the user clicks on the button with text “Six”, 3 times and the button with text “Four”, 4 times?index.html:
```html
<html>
<head>
<style>
.onstrike {
color: blue;
}
</style>
</head>
<body>
<div id="app">
<div :class="{onstrike:changeStrike}" id="run">{{ run }}</div>
<button @click="run+=4">Six</button>
<button @click="run+=3">Four</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</body>
</html>
```
app.js:
```javascript
new Vue({
el: '#app',
data: { run: 0 },
computed: {
changeStrike() {
return this.run % 2 === 0 ? true : false
},
},
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be the color and font-weight of the text “IITM online degree”?index.html:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.active {
color: blue;
}
.bold {
font-weight: bold;
}
</style>
</head>
<body>
<div id="app">
<Home class="bold" />
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</html>
```
app.js:
```javascript
Vue.component('Home', {
template: `<div class='active'>
IITM online degree
</div>`,
})
new Vue({
el: '#app',
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered on the screen?index.html:
```html
<body>
<div id="app">
<template v-for="cont in contributions">
<div>{{cont.player}}: {{cont.run}}/{{partnerShip}}</div>
</template>
</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',
data: {
partnerShip: 210,
contributions: [
{ player: 'Rohit', run: 100 },
{ player: 'Kohli', run: 110 },
],
},
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered inside the div with ID “collections”, when the user selects the option “Type Two” ?```html
index.html:
<body>
<div id="app">
<div>
<select v-model="collType">
<option value="all">All</option>
<option value="typeOne">Type One</option>
<option value="typeTwo">Type Two</option>
</select>
</div>
<div id="collections">
<Numbers :numbers="numbers" v-show="collType==='all' "
/></Numbers>
<Numbers :numbers="typeOne" v-show="collType==='typeOne' "
/></Numbers>
<Numbers :numbers="typeTwo" v-show="collType==='typeTwo' "
/></Numbers>
</div>
</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
Vue.component('Numbers', {
template: `<div>
<span v-for="num in numbers">
{{num}}
</span></div>`,
props: ['numbers'],
})
new Vue({
el: '#app',
data: {
numbers: [2, 3, 4, 6, 7],
collType: 'typeOne',
},
computed: {
typeOne() {
return this.numbers.filter((num) => num % 2 === 0)
},
typeTwo() {
return this.numbers.filter((num) => num % 2 !== 0)
},
},
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”. Suppose the user types “Apple” in the input box (after removing the existing text, if any). What will be rendered inside the div with ID “result”?index.html:
```html
<body>
<div id="app">
<custom-input v-model="searchText"></custom-input>
<div id="result">Searching for: {{searchText}}</div>
</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
Vue.component('custom-input', {
props: ['value'],
template: `
<input
v-bind:value="value"
v-on:input="$emit('input', $event.target.value)"
>
`
})
new Vue({
el: '#app',
data: { searchText: 'type something ...' },
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. Suppose the application is running on ‘http://127.0.0.1:8080/’. If the user visits the application for the first time and clicks on the button “Go to profile”, what will be displayed on the screen?index.html:
```html
<body>
<div id="app">
<router-view></router-view>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
</body>
```
app.js:
```javascript
const Profile = {
template: `<div> Welcome {{this.$route.params.name}}</div>`,
}
const Home = {
template: `<div> This is home page
<button @click='goToProfile'> Go to profile </button>
</div>`,
methods: {
goToProfile() {
this.$router.push({ name: 'profile', params: { name: 'narendra' } })
}
},
}
const router = new VueRouter({
routes: [
{ path: '/profile/:name', name: 'profile', component: Profile },
{ path: '/', component: Home },
],
})
new Vue({
el: '#app',
router,
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. Suppose the application is running on ‘http://127.0.0.1:8080/’. What will be rendered for the URL “http://127.0.0.1:8080/#/” ?index.html:
```html
<body>
<div id="app">
<router-view></router-view>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
</body>
```
```javascript
app.js:
const Movies = {
template: `<div><ul>
<div>Movies</div>
<router-view />
</ul></div>`,
}
const Error = {
template: `<div> Some Error</div>`,
}
const Hindi = {
template: `<div><ul>
<li v-for='movie in hindiMovies'>{{movie.name}}</li>
</ul></div>`,
data() {
return {
movies: [
{ name: 'Soley', language: 'hindi' },
{ name: 'Dexter', language: 'english' },
],
}
},
computed: {
hindiMovies() {
return this.movies.filter((movie) => {
return movie.language === 'english'
})
},
},
}
const router = new VueRouter({
routes: [
{
path: '/',
component: Movies,
children: [
{ path: 'hindi', component: Hindi },
{ path: '*', component: Error },
],
},
],
})
new Vue({
el: '#app',
router,
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered inside the “custom-comp” component?index.html:
```html
<body>
<div id="app">
<custom-comp ref="custom" />
</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
Vue.component('custom-comp', {
data() {
return { name: 'Rohit Sharma' }
},
template: `<div>Welcome {{name}}</div>`,
})
new Vue({
el: '#app',
mounted() {
this.$refs.custom.name = 'Virat Kohli'
},
})
```
Which of the following is the correct way to do class binding in Vue (to apply ‘classA’ on the div element), if the data object in the Vue constructor is defined as below? ```
data : {
classObj : {
classA : true,
classB : false
},
classA : true,
classB : false,
}
```
```html
<div :class="{classA : classA, classB : classB}"></div>
```
```html
<div :class="{classA : 'classA', classB : 'classB'}"></div>
```
```html <div :class = "classObj"></div> ```

```html
<div :class="{classObj}"></div>
```
Which of the following shows the correct output, if the javascript program written below is executed? ```javascript
new Promise((reject, resolve) => {
let a = 2 * 4 || 0 / 4;
let b = 3 * 4 && 0 / 4;
if (a > b) resolve(a);
else reject(b);
})
.then((d) => console.log("Passed:", d))
.catch((e) => console.log("Failed:", e))
.finally((d) => {
console.log("About to finish");
return "Over";
})
.then((d) => console.log("Finished !!", d));
```

Suppose you own a company where you want to hire candidates for an upcoming project on a deputation basis, and you have received a lot of applications. On discussing with your team members, you decided to shortlist the candidates based on the following 2 criteria:
1. The candidate must have at least 3 years of experience
2. The candidate's age must be less than 30 years
Fill in the `code1` & `code2`, which can be used in Vuex Store to update the "shortlisted" state variable with the objects of those candidates who satisfy the above-mentioned criteria. Also, predict the length of the state variable "shortlisted", after the mutation has completed its execution.
```javascript
const store = new Vuex.Store({
state : {
candidates : [
{
name : 'sample1',
age : 28,
experience : 2.5
},
{
name : 'sample2',
age : 35,
experience : 3.5
},
{
name : 'sample3',
age : 32,
experience : 3
},
{
name : 'sample4',
age : 38,
experience : 2
},
],
shortlisted : []
},
mutations : {
update_final(state, minimum) {
for (candidate of state.candidates)
code2
},
},
actions : {
send_task : function (context) {
code1
}
}
})
```
```
code1: this.$store.commit("update_final", 2);
code2: if (candidate.experience >= minimum && candidate.age < 30)
state.shortlisted.push(company)
Length: 3
```
```
code1: context.commit("update_final", 2);
code2: if (experience >= minimum && candidate.age < 30)
state.shortlisted.push(company)
```
Length: 2
```javascript
code1: this.$store.commit("update_final", 3);
code2: if (experience >= minimum && candidate.age < 30)
state.shortlisted.push(company)
```
Length: 3
```
code1: context.commit("update_final", 3);
code2: if (candidate.experience >= minimum && candidate.age < 30)
state.shortlisted.push(company)
```
Length: 2
Consider the following javascript program, and predict the output, if executed. ```javascript
let propA = 10;
const obj1 = {
propA : 20,
propB : function () {
console.log(propA, this.propA)
}
}
const obj2 = {
propA : 30,
propB : function () {
let func = () => console.log(propA, this.propA)
func()
}
}
obj2.propB.call(obj1);
```
Consider the following javascript program, and predict the output, if executed. Also, predict the minimum time taken (in seconds) to log the value “Executing” on the console. ```javascript
async function some () {
let promise = await new Promise((res, rej) => {
setTimeout(() => res("Execution Started"), 1000)
});;
let a = await promise;
let b = a.replace("e", "")
return new Promise ((rej, res) => {
let c = a + "\n" + b;
rej(c);
})
}
some().then(d => console.log(d)
).catch(e => console.log("Error"))
console.log("Executing")
```
Consider the following JavaScript program. What will be logged on to the console?```javascript
const p = function (t) {
return new Promise(((resolve, reject) => {
setTimeout((() => {
resolve(t)
}), t * 1000)
}))
}
data = []
asyncFunc = async function () {
p1 = await p(1)
p2 = await p(2)
data.push(p2)
data.push(p1)
}
asyncFunc()
data.push('Outer')
console.log(data)
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered inside the div for ID “run”, if the user clicks on the button with text “Six”, 3 times and the button with text “Four”, 4 times?index.html:
```html
<html>
<head>
<style>
.onstrike {
color: blue;
}
</style>
</head>
<body>
<div id="app">
<div :class="{onstrike: changeStrike}" id="run">{{run}}</div>
<button @click="run+=4">Six</button>
<button @click="run+=3">Four</button>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js" type="module"></script>
</body>
</html>
```
app.js:
```javascript
new Vue({
el: '#app',
data: { run: 0 },
computed: {
changeStrike() {
return this.run % 2 === 0 ? true : false
},
},
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered inside the div with ID “collections”, when the browser loads the application for the first time?index.html:
```html
<body>
<div id="app">
<div>
<select v-model="collType">
<option value="all">All</option>
<option value="typeOne">Type One</option>
<option value="typeTwo">Type Two</option>
</select>
</div>
<div id="collections">
<Numbers :numbers="numbers" v-show="collType==='all'"></Numbers>
<Numbers :numbers="typeOne" v-show="collType==='typeOne'"></Numbers>
<Numbers :numbers="typeTwo" v-show="collType==='typeTwo'"></Numbers>
</div>
</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
Vue.component('Numbers', {
template: `<div>
<span v-for="num in numbers">
{{num}}
</span></div>`,
props: ['numbers'],
})
new Vue({
el: '#app',
data: {
numbers: [2, 3, 4, 6, 7],
collType: 'typeOne',
},
computed: {
typeOne() {
return this.numbers.filter((num) => num % 2 === 0)
},
typeTwo() {
return this.numbers.filter((num) => num % 2 !== 0)
},
}
})
```
Consider the following Vue application with markup “index.html” and javascript file “app.js”.
Consider the following Vue application with markup “index.html” and javascript file “app.js”. What will be rendered inside the router-view component of Movies component for the URL “http://127.0.0.1:8080/#/hindi”?index.html:
```html
<body>
<div id="app">
<router-view></router-view>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"
></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"
></script>
<script src="app.js" type="module"></script>
</body>
```
app.js:
```javascript
const Movies = {
template: `<div><ul>
<div>Movies</div>
<router-view />
</ul></div>`,
}
const Error = {
template: `<div> Some Error</div>`,
}
const Hindi = {
template: `<div><ul>
<li v-for='movie in hindiMovies'>{{ movie.name }}</li>
</ul></div>`,
data() {
return {
movies: [
{ name: 'Soley', language: 'hindi' },
{ name: 'Dexter', language: 'english' },
],
}
},
computed: {
hindiMovies() {
return this.movies.filter((movie) => {
return movie.language === 'english'
})
},
},
}
const router = new VueRouter({
routes: [
{
path: '/',
component: Movies,
children: [
{ path: 'hindi', component: Hindi },
{ path: '*', component: Error },
],
},
],
})
new Vue({
el: '#app',
router,
})
```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 core topics, concepts, and principles essential for the exam, along with key equations (where applicable) and Mermaid knowledge graphs to visualize relationships.
number, string, boolean, null, undefined, symbol, BigInt. Note: int/char are not primitive in JS (Q2).const vs let:
const: Block-scoped, cannot be reassigned (but objects/arrays can be mutated).let: Block-scoped, can be reassigned.First-Order vs Higher-Order Functions:
map, filter).Closures:
Example:
function outer() {
let x = 10;
return function inner() { console.log(x); }; // Closure
}Promises & Async/Await:
pending → fulfilled (resolved) or rejected.async/await: Syntactic sugar for promises. await pauses execution until the promise settles..catch() or try/catch with await.Example (Q25, Q28, Q29):
new Promise((resolve, reject) => {
if (success) resolve(value);
else reject(error);
})
.then(d => console.log(d))
.catch(e => console.log(e))
.finally(() => console.log("Done"));Arrow Functions vs Regular Functions:
this from the surrounding scope (lexical this).this (dynamic, depends on how called).Example (Q27):
const obj = {
propA: 10,
func: () => console.log(this.propA) // `this` is global/window (undefined in strict mode)
};JAMStack:
API Design:
/users instead of /getUsers).Authentication/Authorization:
OAuth:
CSRF (Cross-Site Request Forgery):
CORS (Cross-Origin Resource Sharing):
Access-Control-Allow-* (e.g., Access-Control-Allow-Origin).Cookies vs Local/Session Storage: | Feature | Cookies | Local Storage | Session Storage | |-----------------------|-----------------------|------------------------|------------------------| | Storage Location | Browser + Server | Browser (client-side) | Browser (client-side) | | Persistence | Configurable (expire) | Persistent | Session-only | | Capacity | ~4KB | ~5MB | ~5MB | | Sent with Requests| Yes (automatically) | No | No |
Use Cases:
Core Concepts:
v-model, v-bind).Directives:
v-if/v-show: Conditional rendering.v-for: Looping.v-bind: Dynamic attributes (e.g., :class).v-on: Event handling (e.g., @click).created, mounted, updated, destroyed.Components:
<component :is="componentName">.Class/Style Binding:
:class="{ 'classA': isActive, 'classB': isError }" (Q20).:class="[classA, { classB: isActive }]".Computed Properties vs Methods:
Vue Router:
:id in paths (e.g., /user/:id).this.$router.push({ name: 'routeName', params: {...} }) (Q17, Q18).*): Must be last in routes array (matches unmatched paths) (Q23).Vuex (State Management):
state, getters, mutations, actions, modules.Best Practices:
Event Handling:
.prevent, .stop, .once.$emit in child, @custom-event in parent.Forms & v-model:
.lazy, .number, .trim.Conditional Rendering:
v-if vs v-show: v-if removes DOM element; v-show toggles display: none.Polling vs Webhooks vs WebSockets: | Mechanism | Direction | Connection | Use Case | |----------------|-----------------|-------------------|------------------------------| | Polling | Client → Server | Short-lived | Periodic checks (e.g., emails) | | Webhooks | Server → Client | HTTP callback | Real-time notifications (e.g., GitHub) | | WebSockets | Bidirectional | Persistent | Chat apps, live updates |
Server-Sent Events (SSE):
Message Brokers (Celery + Redis):
Task Execution:
task.delay(): Immediate dispatch.task.apply_async(countdown=N): Dispatch after N seconds (Q4, Q22).Components:
Credentials in Fetch:
credentials: 'include': Send cookies in cross-origin requests.credentials: 'omit': Exclude cookies.credentials: 'same-origin': Default (send cookies for same origin only) (Q24).Request Methods:
GET, POST, PUT, DELETE, PATCH, OPTIONS (preflight for CORS).Headers:
Access-Control-Allow-Origin: Specifies allowed origins.Content-Type: application/json, multipart/form-data, etc.CORS (Cross-Origin Resource Sharing):
OPTIONS request to check if actual request is safe.Headers:
Access-Control-Allow-Origin: * or specific origin.Access-Control-Allow-Methods: Allowed HTTP methods.CSRF (Cross-Site Request Forgery):
Mitigation:
OAuth 2.0:
Celery:
PENDING, STARTED, SUCCESS, FAILURE, RETRIED.max_retries and default_retry_delay.Celery Beat.Redis:
Dynamic Class Binding (Q12, Q13):
<div :class="{ onstrike: isEven }">...</div>
computed: {
isEven() { return this.run % 2 === 0; }
}Vue Router (Q17, Q18):
/user/:id → Access via this.$route.params.id.this.$router.push({ name: 'user', params: { id: 1 } }).Vuex Store (Q26):
mutations: {
updateFinal(state, { minExperience, maxAge }) {
state.shortlisted = state.candidates.filter(c =>
c.experience >= minExperience && c.age < maxAge
);
}
},
actions: {
sendTask({ commit }) {
commit('updateFinal', { minExperience: 3, maxAge: 30 });
}
}Component Communication:
$emit + @event.javascript function outer() { let x = 10; return function inner() { console.log(x); }; // x is preserved } const closure = outer(); closure(); // Output: 10 ``javascript new Promise((resolve, reject) => { let a = 2 * 4 || 0 / 4; // a = 8 (2*4 is truthy) let b = 3 * 4 && 0 / 4; // b = 0 (0/4 is falsy) if (a > b) resolve(a); else reject(b); }) .then(d => console.log("Passed:", d)) .catch(e => console.log("Failed:", e)); // Output: Failed: 0 ``this (Q27): ``javascript const obj1 = { propA: 20 }; const obj2 = { propA: 30, propB: function() { let func = () => console.log(this.propA); // this is obj1 (lexical) func.call(obj1); // Output: 20 } }; obj2.propB.call(obj1); ``javascript computed: { changeStrike() { return this.run % 2 === 0; // Toggles class based on run } } ``javascript mutations: { updateFinal(state, { minExperience, maxAge }) { state.shortlisted = state.candidates.filter(c => c.experience >= minExperience && c.age < maxAge ); } } ``html <div :class="{ classA: classA, classB: classB }"></div> <!-- OR --> <div :class="classObj"></div> <!-- classObj = { classA: true, classB: false } --> ``### Approach 1: Immediate execution
send_email.delay()
### Approach 2: Delayed execution (10 seconds)
send_email.apply_async(countdown=10)
JavaScript:
this binding, and promise/async-await behavior.== and ===, truthy/falsy values.Vue.js:
computed vs methods.v-bind, v-model, and dynamic components.Web Concepts:
Celery/Redis:
Security: