Quiz Space

September 2022 term · Modern Application Development II · BSCS2006

MAD 2 Quiz 1: 16 October 2022 (September 2022 term)

The IIT Madras BS Modern Application Development II (MAD 2) Quiz 1 paper sat on 16 Oct 2022, in the September 2022 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
14
MSQ
2

Updated

Official paper: IIT M QUIZ 1 FOUNDATION DAD DIPLOMA QPD2 16 Oct 2022 · No negative marking.

Question 1

+2 marksOne correct option

Which of the following statements is correct regarding javascript language?

  1. A

    The equality operator “==” is used to avoid coercion in the language.

  2. B

    A variable declared using the keyword “var” can be used anywhere in the program.

  3. C

    The keyword “break” is used to terminate the execution of the program in the language.

  4. D

    None of these

Show answer

Correct answer

  • D

    None of these

Question 2

+2 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id = "app">
<h3> Header Content </h3>
<main></main>
<h3> Footer Content </h3>
</div>
<script src="app.js"></script>

app.js:

javascript
const main = {
template : `
<div>
<h3> Main Content </h3>
</div>
`
}
const comp = {
'main' : main
}
new Vue({
el : "#app"
})

If the file “index.html” is opened with the help of a browser. What will be rendered on the browser?

  1. A

    Header Content
    Main Content
    Footer Content

  2. B

    The app will show a warning, and nothing will be shown on the browser.

  3. C

    Header Content
    Footer Content

  4. D

    The app will not show any warning, but nothing will be shown on the browser.

Show answer

Correct answer

  • C

    Header Content
    Footer Content

Question 3

+3 marksOne correct option

Consider the below javascript program, and predict the output, if executed.

javascript
var num = 20;
function demo () {
num = 50;
function num () {
console.log("Number is:", num)
}
}
demo()
console.log("Number is:", num)
  1. A

    Number is: 20

  2. B

    Number is: 50

  3. C

    Number is: undefined

  4. D

    Number is:

Show answer

Correct answer

  • A

    Number is: 20

Question 4

+3 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<div id = "app">
<h3>Number : {{total_num}}</h3>
<button @click = "update_num"> Click Me </button>
</div>
<script src="app.js"></script>

app.js:

javascript
new Vue({
el : "#app",
data : {
num : 10
},
computed : {
total_num : function () {
return this.num % 3 == 0 ? this.num * 3 + 5 : this.num / 4 + 6;
}
},
methods : {
update_num : function () {
this.num = this.num < 10 ? this.num * 4 + 1 : this.num * 3 - 5;
}
}
})

If the file “index.html” is opened with the help of a browser. What will be rendered on the browser (excluding the button) for the first time and after clicking the button with the text “Click Me” twice?

  1. A

    Before Click: Number : 8.5
    After Click: Number : 23.5

  2. B

    Before Click: Number : 8.5
    After Click: Number : 70

  3. C

    Before Click: Number : 35
    After Click: Number : 23.5

  4. D

    Before Click: Number : 35
    After Click: Number : 70

Show answer

Correct answer

  • A

    Before Click: Number : 8.5
    After Click: Number : 23.5

Question 5

+3 marksOne correct option

What will be logged on to the console, if the program written below is executed?

javascript
{
let x = 10
{
let getNum = () => {
return x + 10
}
}
console.log(getNum())
}
  1. A

    10

  2. B

    NaN

  3. C

    Undefined

  4. D

    ReferenceError

Show answer

Correct answer

  • D

    ReferenceError

Question 6

+3 marksOne correct option

What will be logged on to the console, if the program written below is executed?

javascript
function outer(x) {
let a = 2
function inner(y) {
function innerMost(z) {
return x + y + z + a
}
return innerMost
}
return inner
}
console.log(outer(19)(20)(30))
  1. A

    Undefined

  2. B

    NaN

  3. C

    Will return a function reference

  4. D

    71

Show answer

Correct answer

  • D

    71

Question 7

+3 marksOne correct option

What will be logged on to the console, if the program written below is executed?

javascript
let x = 10
var y = 10,
z = 10
{
let x = 20
var y = 20
function test() {
var z = 20
}
}
console.log(x, y, z)
  1. A

    10 20 10

  2. B

    20 20 20

  3. C

    10 20 20

  4. D

    10 10 10

Show answer

Correct answer

  • A

    10 20 10

Question 8

+3 marksOne correct option

What will be logged on to the console, if the program written below is executed?

javascript
const obj1 = { x: 10, y: 20 },
obj2 = { x: 30, y: 40 }
function area() {
return this.x * this.y
}
function test() {
return area.call(obj2)
}
console.log(test.call(obj1), test.call(obj2))
  1. A

    200, 1200

  2. B

    1200, 200

  3. C

    1200, 1200

  4. D

    200, 200

Show answer

Correct answer

  • C

    1200, 1200

Question 9

+3 marksOne correct option

What will be logged on to the console, if the program written below is executed?

javascript
class Circle {
constructor(r) {
this.r = r
}
}
Circle.prototype.area = function () {
return 3.14 * this.r
}
const obj1 = new Circle(2)
console.log(
Circle.prototype === obj1.__proto__.__proto__,
Circle.prototype === obj1.__proto__
)
  1. A

    false false

  2. B

    false true

  3. C

    true true

  4. D

    true false

Show answer

Correct answer

  • B

    false true

Question 10

+3 marksOne correct option

Consider the following Vue app with markup “index.html” and javascript file “app.js”.

index.html:

html
<html lang="en">
<head>
<style>
.dark-mode {
color: white;
background-color: black;
}
</style>
</head>
<body>
<div id="app">
<h1 :class="{'dark-mode': darkMode}">IITM online degree</h1>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
<script src="app.js"></script>
</body>
</html>

app.js:

javascript
new Vue({
el: '#app',
name: 'app',
data: {
darkMode: false,
},
beforeCreate() {
this.darkMode = true
},
})

What will be the text colour and background colour of text “IITM Online degree”, assuming a normal browser is used, which shows black coloured text on a white background?

  1. A

    Black, White

  2. B

    White, Black

  3. C

    Black, Black

  4. D

    White, White

Show answer

Correct answer

  • A

    Black, White

Question 11

+4.5 marksOne correct option

Consider the below javascript program, and predict the output, if executed.

javascript
var num = 10
const obj1 = {
num : 20,
func : function (key) {
let temp = () => {
console.log("Number 1:", num, "Number 2:", this.num, "Sum:",
this.num + num + key)
}
temp()
}
}
const obj2 = {
num : 30,
func : function (key) {
console.log("Function Called !!", key)
}
}
new_func = obj1.func.bind(obj2, 40)
new_func()
  1. A

    Number 1: 10 Number 2: 20 Sum: 70

  2. B

    Number 1: 10 Number 2: 30 Sum: 80

  3. C

    Number 1: 20 Number 2: 20 Sum: 80

  4. D

    Number 1: 20 Number 2: 30 Sum: 90

Show answer

Correct answer

  • B

    Number 1: 10 Number 2: 30 Sum: 80

Question 12

+4.5 marksOne correct option

What will be logged on to the console, if the program written below is executed.

javascript
function getY() {
return () => this.y
}
const Obj1 = {
y: 15,
getY: getY,
obj3: {
y: 45,
getY: getY,
},
}
console.log(Obj1.obj3.getY()(), Obj1.getY()())
  1. A

    Undefined, Undefined

  2. B

    Undefined, 15

  3. C

    45, 15

  4. D

    45, Undefined

Show answer

Correct answer

  • C

    45, 15

Question 13

+4.5 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<body>
<div id="app">
<h3 id="total">Total: {{total}}</h3>
<h4 id="strike">{{batsmans.strike.name}}: {{batsmans.strike.run}}</h4>
<h4 id="non-strike">{{batsmans.nonStrike.name}}:
{{batsmans.nonStrike.run}}</h4>
<div>
<button @click="total+=1">1</button>
<button @click="total+=2">2</button>
</div>
</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
class Player {
constructor(name) {
this.name = name
this.run = 0
}
}
new Vue({
el: '#app',
data: {
batsmans: {
strike: new Player('Rohit Sharma'),
nonStrike: new Player('Virat Kohli'),
},
total: 30,
},
watch: {
total(newRun, oldRun) {
change = newRun - oldRun
this.batsmans.strike.run += change
if (change % 2 == 0) {
this.changeStrike()
}
},
},
methods: {
changeStrike() {
temp = this.batsmans.strike
this.batsmans.strike = this.batsmans.nonStrike
this.batsmans.nonStrike = temp
},
},
})

If the user clicks on the button with the text “2” twice and “1” once. What will be rendered inside the element with ID “total”, “strike”, and “non-strike”?

  1. A

    Total: 5, Virat Kohli: 0, Rohit Sharma: 5

  2. B

    Total: 5, Rohit Sharma: 5, Virat Kohli: 0

  3. C

    Total: 35, Virat Kohli:3, Rohit Sharma: 2

  4. D

    Total: 35, Rohit Sharma: 3, Virat Kohli: 2

Show answer

Correct answer

  • D

    Total: 35, Rohit Sharma: 3, Virat Kohli: 2

Question 14

+4.5 marksOne correct option

Consider the following Vue application with markup “index.html” and javascript file “app.js”.

index.html:

html
<html lang="en">
<head>
<style>
.sold {
color: red;
}
</style>
</head>
<body>
<div id="app">
<Product
v-for="(product, index) in products"
:product="product"
@buy="buy"
:key="index"
/>
</div>
<script
src="https://cdn.jsdelivr.net/npm/vue@2.7.8/dist/vue.js"></script>
<script src="app.js"></script>
</body>
</html>

app.js:

javascript
const Product = {
template: `<div :class="{sold:product.sold}">
<h4>{{product.name}}</h4>
<h3>Price:{{product.price}}</h3>
<div><button @click="$emit('buy', product.id)"> Buy </button></div>
</div>`,
props: ['product'],
}
new Vue({
el: '#app',
components: { Product },
data() {
return {
products: [
{ id: 1, name: 'Watch', price: '200', sold: true },
{ id: 2, name: 'Mobile', price: '4000', sold: true },
],
}
},
methods: {
buy(id) {
prod = this.products.find((prod) => {
return prod.id == id
})
prod.sold = false
},
},
})

If the user clicks on the button with the text “Buy” corresponding to the product having ID “1”. What will be the text colour of the rendered “Product” component, corresponding to the product having ID “1” and “2”, respectively?

  1. A

    Black, Black

  2. B

    Black, Red

  3. C

    Red, Black

  4. D

    Red, Red

Show answer

Correct answer

  • B

    Black, Red

Question 15

+2 marksOne or more correct options

Which of the following statement(s) is/are false regarding javascript language?

Select all that apply.

  1. A

    The variables declared outside all functions using “var” keyword are initialized with the value “undefined”, until the code execution reaches the initialization statement for that particular variable.

  2. B

    The variables declared outside all functions using “const” keyword are initialized with the value “null”, until the code execution reaches the initialization statement for that particular variable.

  3. C

    The function expressions in the language are not hoisted.

  4. D

    A javascript object can not have its own functions or methods.

Show answer

Correct answers

  • B

    The variables declared outside all functions using “const” keyword are initialized with the value “null”, until the code execution reaches the initialization statement for that particular variable.

  • D

    A javascript object can not have its own functions or methods.

Question 16

+2 marksOne or more correct options

Which of the following statement(s) is/are true regarding the state of a web application?

Select all that apply.

  1. A

    The system state is usually a huge collection of information.

  2. B

    The system state is dependent on the user interface.

  3. C

    Your Amazon wish list is an example of application state.

  4. D

    All of these

Show answer

Correct answers

  • A

    The system state is usually a huge collection of information.

  • C

    Your Amazon wish list is an example of application state.