MAD Study Hub

Home / Past papers / MAD2 Quiz 1 / this paper

IIT M QUIZ 1 FOUNDATION DAD DIPLOMA QPD1 16 Oct 2022 - 16 Oct 2022

MAD2 Quiz 117 questions50 marks15 MCQ · 2 MSQFoundation / Diploma / QPD1
Elapsed 00:00
Q1MCQ0 marks
question figure
Text of the picture (copyable)
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)
  1. YES
  2. NO
Q2MCQ2 marks
Which of the following statements is correct regarding javascript language?
  1. The equality operator “==” is used to avoid coercion in the language.
  2. A variable declared using the keyword “var” can be used anywhere in theprogram.
  3. The keyword “break” is used to terminate the execution of the program in thelanguage.
  4. None of these
Q3MCQ2 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”. If the file “index.html” is opened with the help of a browser. What will be rendered on the browser?
Text of the picture (copyable)
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"
})
```
  1. Header ContentMain ContentFooter Content
  2. The app will show a warning, and nothing will be shown on the browser.
  3. Header ContentFooter Content
  4. The app will not show any warning, but nothing will be shown on the browser.
Q4MCQ3 marks
Consider the below javascript program, and predict the output, if executed. question figure Consider the below javascript program, and predict the output, if executed.
Text of the picture (copyable)
```javascript
var num = 20;

function demo () {
    num = 50;

    function num () {
        console.log("Number is:", num)
    }
}
demo()
console.log("Number is:", num)
```
  1. Number is: 20
  2. Number is: 50
  3. Number is: undefined
  4. Number is:
Q5MCQ3 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”. 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?
Text of the picture (copyable)
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;
        }
    }
})
```
  1. Before Click: Number : 8.5After Click: Number : 23.5
  2. Before Click: Number : 8.5After Click: Number : 70
  3. Before Click: Number : 35After Click: Number : 23.5
  4. Before Click: Number : 35After Click: Number : 70
Q6MCQ3 marks
What will be logged on to the console, if the program written below is executed? question figure What will be logged on to the console, if the program written below is executed?
Text of the picture (copyable)
```javascript
{
    let x = 10
    {
        let getNum = () => {
            return x + 10
        }
    }
    console.log(getNum())
}
```
  1. 10
  2. NaN
  3. Undefined
  4. ReferenceError
Q7MCQ3 marks
What will be logged on to the console, if the program written below is executed? question figure What will be logged on to the console, if the program written below is executed?
Text of the picture (copyable)
```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. Undefined
  2. NaN
  3. Will return a function reference
  4. 71
Q8MCQ3 marks
What will be logged on to the console, if the program written below is executed? question figure What will be logged on to the console, if the program written below is executed?
Text of the picture (copyable)
```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. 10 20 10
  2. 20 20 20
  3. 10 20 20
  4. 10 10 10
Q9MCQ3 marks
What will be logged on to the console, if the program written below is executed? question figure What will be logged on to the console, if the program written below is executed?
Text of the picture (copyable)
```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. 200, 1200
  2. 1200, 200
  3. 1200, 1200
  4. 200, 200
Q10MCQ3 marks
What will be logged on to the console, if the program written below is executed? question figure What will be logged on to the console, if the program written below is executed?
Text of the picture (copyable)
```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. false false
  2. false true
  3. true true
  4. true false
Q11MCQ3 marks
Consider the following Vue app with markup “index.html” and javascript file “app.js”. question figure Consider the following Vue app with markup “index.html” and javascript file “app.js”. 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?
Text of the picture (copyable)
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
    },
})
```
  1. Black, White
  2. White, Black
  3. Black, Black
  4. White, White
Q12MCQ4.5 marks
Consider the below javascript program, and predict the output, if executed. question figure Consider the below javascript program, and predict the output, if executed.
Text of the picture (copyable)
```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. Number 1: 10 Number 2: 20 Sum: 70
  2. Number 1: 10 Number 2: 30 Sum: 80
  3. Number 1: 20 Number 2: 20 Sum: 80
  4. Number 1: 20 Number 2: 30 Sum: 90
Q13MCQ4.5 marks
What will be logged on to the console, if the program written below is executed. question figure What will be logged on to the console, if the program written below is executed.
Text of the picture (copyable)
```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. Undefined, Undefined
  2. Undefined, 15
  3. 45, 15
  4. 45, Undefined
Q14MCQ4.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”. 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”?
Text of the picture (copyable)
```html
index.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:
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
        },
    }
})
```
  1. Total: 5, Virat Kohli: 0, Rohit Sharma: 5
  2. Total: 5, Rohit Sharma: 5, Virat Kohli: 0
  3. Total: 35, Virat Kohli:3, Rohit Sharma: 2
  4. Total: 35, Rohit Sharma: 3, Virat Kohli: 2
Q15MCQ4.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”. 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?
Text of the picture (copyable)
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
        },
    },
})
```
  1. Black, Black
  2. Black, Red
  3. Red, Black
  4. Red, Red
Q16MSQ2 marksselect all that apply
Which of the following statement(s) is/are false regarding javascript language?
  1. The variables declared outside all functions using “var” keyword are initializedwith the value “undefined”, until the code execution reaches the initialization statement for thatparticular variable.
  2. The variables declared outside all functions using “const” keyword areinitialized with the value “null”, until the code execution reaches the initialization statement forthat particular variable.
  3. The function expressions in the language are not hoisted.
  4. A javascript object can not have its own functions or methods.
Q17MSQ2 marksselect all that apply
Which of the following statement(s) is/are true regarding the state of a web application?
  1. The system state is usually a huge collection of information.
  2. The system state is dependent on the user interface.
  3. Your Amazon wish list is an example of application state.
  4. All of these

Answer key

  1. Q1 (MCQ, 0 marks): A
  2. Q2 (MCQ, 2 marks): D
  3. Q3 (MCQ, 2 marks): C
  4. Q4 (MCQ, 3 marks): A
  5. Q5 (MCQ, 3 marks): A
  6. Q6 (MCQ, 3 marks): D
  7. Q7 (MCQ, 3 marks): D
  8. Q8 (MCQ, 3 marks): A
  9. Q9 (MCQ, 3 marks): C
  10. Q10 (MCQ, 3 marks): B
  11. Q11 (MCQ, 3 marks): A
  12. Q12 (MCQ, 4.5 marks): B
  13. Q13 (MCQ, 4.5 marks): C
  14. Q14 (MCQ, 4.5 marks): D
  15. Q15 (MCQ, 4.5 marks): B
  16. Q16 (MSQ, 2 marks): B, D
  17. Q17 (MSQ, 2 marks): A, C

Concepts this paper tests

Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.

Summary of Core Topics, Concepts, Principles, and Equations

JavaScript and Vue.js

  1. JavaScript Basics

    • Variable Declarations: var, let, const
    • Hoisting and Scope: Understanding function and block scope.
    • Closures and this Context: How this behaves in different contexts and with arrow functions.
    • Recursion and Stack Overflow: Understanding recursive functions and their potential to cause stack overflow.
  1. Vue.js Basics

    • Vue Instance: Creating and mounting a Vue instance.
    • Data Binding: Using {{ }} for data binding in templates.
    • Computed Properties: Defining and using computed properties.
    • Methods: Defining and using methods in Vue.
    • Event Handling: Using @click for event handling.
    • Components: Creating and using components in Vue.
    • Lifecycle Hooks: Using created lifecycle hook.
    • Conditional Rendering: Using :class for conditional rendering.
  1. JavaScript Objects and Classes

    • Object Properties and Methods: Defining and accessing object properties and methods.
    • Classes and Constructors: Defining classes and constructors.
    • Static Methods: Defining and using static methods.
    • Prototypes and Inheritance: Understanding prototypes and inheritance in JavaScript.
  1. JavaScript Functions

    • Function Expressions and Declarations: Differences between function expressions and declarations.
    • Arrow Functions: Understanding arrow functions and their lexical this.
    • bind, call, and apply: Using these methods to bind context.
  1. Vue.js Components and Props

    • Component Registration: Registering components in Vue.
    • Props: Passing props to components.
    • Custom Events: Emitting and handling custom events.
  1. Vue.js Watchers

    • Watchers: Using watchers to react to data changes.
  1. Vue.js Styling

    • Conditional Styling: Using :class for conditional styling.
  1. JavaScript State Management

    • State Management: Understanding application and system state.