MAD Study Hub

Home / Past papers / MAD2 Quiz 1 / this paper

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

MAD2 Quiz 117 questions50 marks14 MCQ · 3 MSQFoundation / Diploma / QPE3
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
question figure
Text of the picture (copyable)
Consider the following Vue application with markup "index.html" and javascript file "app.js".

index.html:

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

app.js:

```javascript
const main = {
    template : `
        <div>
            <h3> Main Section </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. Header SectionMain SectionFooter Section
  2. The app will show a warning, and nothing will be shown on the browser.
  3. Header SectionFooter Section
  4. The app will not show any warning, but nothing will be shown on the browser.
Q3MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below javascript program, and predict the output, if executed.

```javascript
var xyz = 40;

function demo () {
    xyz = 20;

    function xyz () {
        console.log("Number is:", xyz)
    }
}
demo()
console.log("Number is:", xyz)
```
  1. Number is: 20
  2. Number is: 40
  3. Number is: undefined
  4. Number is:
Q4MCQ3 marks
question figure
Text of the picture (copyable)
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 : 9,
    },
    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. Before Click: Number : 32After Click: Number : 149
  2. Before Click: Number : 32After Click: Number : 32.5
  3. Before Click: Number : 8.25After Click: Number : 106
  4. Before Click: Number : 8.25After Click: Number : 149
Q5MCQ3 marks
question figure
Text of the picture (copyable)
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. 20
  2. NaN
  3. Undefined
  4. ReferenceError
Q6MCQ3 marks
question figure
Text of the picture (copyable)
What will be logged on to the console, if the program written below is executed?
```javascript
function outer(x) {
  let a = 20
  function inner(y) {
    function innerMost(z) {
      return x + y + z + a
    }
    return innerMost
  }
  return inner
}
console.log(outer(19)(20)(30))
```
  1. Undefined
  2. 89
  3. Will return a function reference
  4. 71
Q7MCQ3 marks
question figure
Text of the picture (copyable)
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 z = 20
  function test() {
    var y = 20
  }
}
console.log(x, y, z)
```
  1. question figure
    text
    10 20 10
  2. question figure
    text
    20 20 20
  3. question figure
    text
    10 20 20
  4. question figure
    text
    10 10 20
Q8MCQ3 marks
question figure
Text of the picture (copyable)
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(obj1)
}

console.log(test.call(obj1), test.call(obj2))
```
  1. 200, 1200
  2. 1200, 200
  3. 1200, 1200
  4. 200, 200
Q9MCQ3 marks
question figure
Text of the picture (copyable)
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.prototype,
  Circle.prototype === obj1.__proto__
)
```
  1. question figure
    text
    false false
  2. question figure
    text
    false true
  3. question figure
    text
    true true
  4. question figure
    text
    true false
Q10MCQ3 marks
question figure
Text of the picture (copyable)
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,
    },
    created() {
        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. Black, White
  2. White, Black
  3. Black, Black
  4. White, White
Q11MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below javascript program, and predict the output, if executed.

```javascript
var num = 30

const obj1 = {
    num : 10,
    func : function (key) {
        let temp = () => {
            console.log("Number 1:", num, "Number 2:", this.num, "Sum:",
            this.num + num + key)
        }
        temp()
    }
}

const obj2 = {
    num : 20,
    func : function (key) {
        console.log("Function Called !!", key)
    }
}

new_func = obj1.func.bind(obj2, 50)
new_func()
```
  1. Number 1: 10 Number 2: 30 Sum: 90
  2. Number 1: 20 Number 2: 30 Sum: 100
  3. Number 1: 30 Number 2: 20 Sum: 100
  4. Number 1: 30 Number 2: 10 Sum: 90
Q12MCQ4.5 marks
question figure
Text of the picture (copyable)
What will be logged on to the console, if the program written below is executed?

```javascript
function getY() {
  return () => this.y
}

const Obj1 = {
  y: 45,
  getY: getY,
  obj3: {
    y: 15,
    getY: getY,
  },
}

console.log(Obj1.obj3.getY()(), Obj1.getY()())
```
  1. Undefined, Undefined
  2. 45, 15
  3. 15, 45
  4. 15, Undefined
Q13MCQ4.5 marks
question figure
Text of the picture (copyable)
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" four times and "1" twice. What will be rendered inside the element with ID "total", "strike", and "non-strike"?
  1. Total: 10, Virat Kohli: 0, Rohit Sharma: 10
  2. Total: 40, Rohit Sharma: 6, Virat Kohli: 4
  3. Total: 40, Virat Kohli:6, Rohit Sharma: 4
  4. Total: 10, Rohit Sharma: 0, Virat Kohli: 10
Q14MCQ4.5 marks
question figure
Text of the picture (copyable)
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 "2". What will be the text colour of the rendered "Product" component, corresponding to the product having ID "1" and "2", respectively?
  1. Black, Black
  2. Black, Red
  3. Red, Black
  4. Red, Red
Q15MSQ2 marksselect all that apply
Which of the following statement(s) is/are false 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. The JavaScript language is a dynamically typed language
Q16MSQ2 marksselect all that apply
Which of the following statement(s) is/are true 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 false 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. Your Amazon wish list is an example of system state

Answer key

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

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.