uiz Space

January 2024 term · Modern Application Development II · BSCS2006

Modern Application Development II Quiz 1: 25 February 2024 (January 2024 term)

The IIT Madras BS Modern Application Development II (MAD 2) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term: 16 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
16
Marks
50
Duration
120 min
MCQ
13
MSQ
3

Updated

Official paper: IIT M DIPLOMA AN2 EXAM QDD2 25 Feb 2024 · No negative marking.

Question 1

+3 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
function checkThis() {
return this.name
}
const Obj1 = {
name: 'Obj1',
checkThis: checkThis,
}
const Obj2 = {
name: 'Obj2',
checkThis: checkThis,
}
console.log(Obj2.checkThis(), Obj1.checkThis.call(Obj2))
  1. A

    Obj1 Obj1

  2. B

    Obj1 Obj2

  3. C

    Obj2 Obj1

  4. D

    Obj2 Obj2

Show answer

Correct answer

  • D

    Obj2 Obj2

Question 2

+4.5 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
const stateManager = function () {
let defaultState = false
function alterState() {
defaultState = !defaultState
}
return {
currentState() {
return defaultState
},
changeState() {
alterState()
},
}
}
const sm1 = stateManager()
sm1.changeState()
const sm2 = stateManager()
console.log(sm1.currentState(), sm2.currentState())
  1. A

    true true

  2. B

    true false

  3. C

    false true

  4. D

    false false

Show answer

Correct answer

  • B

    true false

Question 3

+2 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
const player = {
name: 'Rohit',
state: 'Maharastra',
}
const batsman = Object.create(player)
console.log(batsman.name)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 4

+2 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
const emails = [
'user1@study.iitm.ac.in',
'user2@gmail.com',
'user3@study.iitm.ac.in',
]
const studentsEmail = emails.filter((email) =>
email.endsWith('study.iitm.ac.in')
)
console.log(studentsEmail)
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 5

+3 marksOne correct option

Consider the following Vue application with markup index.html and JavaScript app.js

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"></script>
</body>

app.js

javascript
new Vue({
el: '#app',
template: `
<div>
{{text}}
<div>
<input type="text" v-model="userInput" />
<div id="match">
{{hasMatched?"Not Matched":"Matched"}}
</div>
</div>
</div>`,
data: {
text: 'This is text',
userInput: null,
},
computed: {
hasMatched() {
return this.text.startsWith(this.userInput)
},
},
})

Suppose the application is running on “http://localhost:8080/”. If the User inputs “This” in the input box. What will be rendered inside the div with id “match”?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 6

+4.5 marksOne correct option

Consider the following Vue application with markup index.html and JavaScript app.js

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"></script>
</body>

app.js

javascript
new Vue({
el: '#app',
template: `<div>
<div id="holiday">{{isHoliday?"Holiday":"Not Holiday"}}</div>
<button @click="increeseCount">Increese Count</button>
</div>`,
data: {
count: 1,
isHoliday: false,
},
watch: {
count() {
if (this.count % 5 == 0) {
this.isHoliday = true
}
},
},
methods: {
increeseCount() {
this.count += 6
},
},
})

Suppose the application is running on “http://localhost:8080” if the user clicks on button “Increese Count” 5 times. What will be rendered inside the div with id “holiday”?

  1. A

    Holiday

  2. B

    Not Holiday

  3. C

    true

  4. D

    false

Show answer

Correct answer

  • A

    Holiday

Question 7

+3 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
class Album {
constructor(creator, albumName) {
this.creator = creator
this.albumName = albumName
this.songs = []
}
addSong(song) {
this.songs.push(song)
}
}
class Song {
constructor(name, duration) {
this.name = name
this.duration = duration
this.album = null
}
addAlbum(album) {
this.album = album
}
}
a1 = new Album('creator1', 'Album1')
s1 = new Song('Song1')
a1.addSong(s1)
console.log(a1.songs.length)
  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    None of these

Show answer

Correct answer

  • B

    1

Question 8

+3 marksOne correct option

Consider the following JavaScript code. What will be logged on to the console once the code is executed?

javascript
class Album {
constructor(creator, albumName) {
this.creator = creator
this.albumName = albumName
this.songs = []
}
addSong(song) {
this.songs.push(song)
}
}
class Song {
constructor(name, duration) {
this.name = name
this.duration = duration
this.album = null
}
addAlbum(album) {
this.album = album
}
}
a1 = new Album('creator1', 'Album1')
s1 = new Song('Song1')
s1.addAlbum(a1)
console.log(a1.songs.length)
  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    None of these

Show answer

Correct answer

  • A

    0

Question 9

+3 marksOne or more correct options

Which of the following statement(s) is/are true regarding JavaScript language?

Select all that apply.

  1. A

    Any variable declared using “var” keyword has a global scope.

  2. B

    Any variable declared using “let” keyword has a block based scope.

  3. C

    The language supports the concept of arrays.

  4. D

    The language uses a call stack to execute the functions in the program.

Show answer

Correct answers

  • B

    Any variable declared using “let” keyword has a block based scope.

  • C

    The language supports the concept of arrays.

  • D

    The language uses a call stack to execute the functions in the program.

Question 10

+4.5 marksOne correct option

Consider the below JavaScript program.

javascript
const obj = [{
id: "1"
}, {
id: "2"
}, {
id: "3"
}, {
id: " 4"
}, {
id: " 5 "
}];
const finalObj = obj.map((element) => element.id).map((element) =>
element.trim()).map((element) => parseInt(element)).filter((element) =>
element % 2);
console.log(finalObj, finalObj.length);

What will be the output of the above program, if executed?

  1. A

    [‘1’, ‘3’, ‘5’] 3

  2. B

    [‘2’, ‘4’] 2

  3. C

    [1, 3, 5] 3

  4. D

    [2, 4] 2

  5. E

    [‘1’, ‘2’, ‘3’, ‘4’, ‘5’] 5

  6. F

    [1, 2, 3, 4, 5] 5

Show answer

Correct answer

  • C

    [1, 3, 5] 3

Question 11

+2 marksOne or more correct options

Which of the following is/are example(s) of application state (i.e., system as seen by an individual user)?

Select all that apply.

  1. A

    Shopping cart of an e-commerce application

  2. B

    Loading icons

  3. C

    Currently selected tab in a multipage / document

  4. D

    Followed news items in a news app

Show answer

Correct answers

  • A

    Shopping cart of an e-commerce application

  • D

    Followed news items in a news app

Question 12

+3 marksOne or more correct options

Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    The computed properties are auto triggered when any of the reactive dependencies changes.

  2. B

    The computed properties are cached based on their reactive dependencies.

  3. C

    The watchers need to be manually triggered when the watched property is assigned a new value.

  4. D

    The watchers can be defined globally, and apply to all instances of a Vue component.

Show answer

Correct answers

  • A

    The computed properties are auto triggered when any of the reactive dependencies changes.

  • B

    The computed properties are cached based on their reactive dependencies.

Question 13

+3 marksOne correct option

Which of the following is a valid function definition to return the sum of 2 numbers passed as parameter?

  1. A

    let add = (x, y) => x + y

  2. B

    let add = (x, y) => { x + y; }

  3. C

    function add (x, y) { return x + y; }

  4. D

    All of these

Show answer

Correct answer

  • D

    All of these

Question 14

+4.5 marksOne correct option

Consider the below JavaScript program.

javascript
const property1 = 10;
const obj1 = {
property1: 20,
property2: function () {
console.log(property1, this.property1);
return this.property1;
}
}
const obj2 = {
property1: 30,
property2: () => {
console.log(property1, this.property1);
console.log(this.property2);
}
}
obj2.property2();

What will be the output of the above program, if executed?

  1. A

    10 30
    20

  2. B

    10 30
    undefined

  3. C

    10 undefined
    30

  4. D

    10 undefined
    undefined

  5. E

    10 30
    10 20
    20

  6. F

    10 undefined
    10 undefined
    undefined

Show answer

Correct answer

  • D

    10 undefined
    undefined

Question 15

+2 marksOne correct option

Which of the following is not a valid Vue directive?

  1. A

    v-model

  2. B

    v-click

  3. C

    v-if

  4. D

    v-show

Show answer

Correct answer

  • B

    v-click

Question 16

+3 marksOne correct option

Consider the below javascript program.

javascript
const a = 2;
const b = "";
const obj1 = {
property1: 10,
property2: 20
}
const obj2 = {
a: 1,
b: 2,
...(a && !b && { obj1 })
};
console.log(obj2);

What will be the output of the above program, if executed?

  1. A

    { a: 1, b: 2, property1: 10, property2: 20 }

  2. B

    { a: 1, b: 2, obj1: { property1: 10, property2: 20 } }

  3. C

    { property1: 10, property2: 20 }

  4. D

    { a: 1, b: 2 }

Show answer

Correct answer

  • B

    { a: 1, b: 2, obj1: { property1: 10, property2: 20 } }