MAD Study Hub

Home / MAD2 / Week 3 / Real questions

MAD2 week 3 - real exam questions

60 questions pulled from past papers whose wording matches this week's topics, newest first, duplicates removed. Pick your answers, then press Check answers. Figures and answer keys are the originals.

Elapsed 00:00
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 1MCQ3 marks
A developer has just created a new Vue 2 project using Vue CLI and the following package.json was generated. package.json question figure The developer wants to view the app in the browser locally for development. They run the following command: bash: Which of the following best describes what happens and what the developer should have run instead?
Text of the picture (copyable)
```json
{
  "name": "my-vue-app",
  "version": "0.1.0",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.6.14"
  },
  "devDependencies": {
    "@vue/cli-service": "^5.0.0",
    "babel-eslint": "^10.1.0"
  }
}
```
```
npm run build
```
  1. launches the app on ; the developer should have run npm start to compile for production instead.
    text
    ```
    npm run build
    ```
    ```
    localhost:8080
    ```
  2. and do the same thing — both launch the app at
    text
    ```
    npm run build
    ```
    ```
    npm run serve
    ```
    ```
    localhost:8080
    ```
  3. is correct for local development; is only used for deploying to a server.
    text
    ```
    npm run build
    ```
    ```
    npm run serve
    ```
  4. compiles and bundles the app for production into a folder — it does not start a local server. The developer should have run instead.
    text
    ```
    npm run build
    ```
    /dist
    ```
    npm run serve
    ```
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 2MSQ3 marksselect all that apply
Which of the following is/are the advantage(s) of client-side storage?
  1. Saving web generated documents for offline use.
  2. The data can be stored across devices.
  3. Storing personalized site preferences.
  4. IndexedDB API is a kind of client-side storage which can be used for audio/video files.
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 3MSQ3 marksselect all that apply
Pratham builds a Flask route that generates a PDF report and sends it to the user via email, all inside the route handler without using Celery. A tester notices that the browser takes about 12 seconds to respond, and during that time other users are unable to use the app normally. Which of the following correctly explain this behaviour and what Celery would change?
  1. Flask handles one request at a time per worker, so the long-running task blocks the entire process until it finishes.
  2. Other users' requests are queued and only served after the heavy task completes, making the app feel unresponsive.
  3. Using Celery's would make the task run faster by giving it more CPU cores.
    text
    ```
    .delay()
    ```
  4. With Celery, Flask immediately returns a response to the user while the report generation and email sending happen inside a separate Celery worker process in the background.
MAD2 End Term · 13 Sep 2026 · open the full paper
Practice 4MCQ3 marks
A developer runs the following code in Tab 1 of a browser, then opens the same website in a new Tab 2 (not a duplicate, but a fresh tab typed into the address bar). question figure Which of the following statements correctly describes what happens in Tab 2?
Text of the picture (copyable)
```javascript
// Executed in Tab 1
localStorage.setItem("theme", "dark");
sessionStorage.setItem("cart", "3-items");
```
  1. Both and return their respective values.
    text
    ```javascript
    localStorage.getItem("theme")
    ```
    ```javascript
    sessionStorage.getItem("cart")
    ```
  2. returns "dark", but returns null.
    text
    ```javascript
    localStorage.getItem("theme")
    ```
    ```javascript
    sessionStorage.getItem("cart")
    ```
  3. Both return null
  4. returns "3-items", but returns null.
    text
    ```javascript
    sessionStorage.getItem("cart")
    ```
    ```javascript
    localStorage.getItem("theme")
    ```
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 5MCQ2 marks
A developer opens the Node.js REPL and runs the following line: question figure Why does this fail?
Text of the picture (copyable)
```javascript
const heading = document.querySelector("h1")
```
  1. Node.js cannot execute JavaScript from the terminal.
  2. The Node.js runtime does not provide browser DOM APIs like
    text
    document
  3. works only after using
    text
    ```javascript
    document.querySelector()
    ```
    ```
    setTimeout()
    ```
  4. V8 can execute only arithmetic expressions, not DOM code.
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 6MCQ2 marks
Consider the following javascript code: question figure The above code is initially loaded on the browser and then the browser is refreshed two times. What will be the final output?
Text of the picture (copyable)
```javascript
function addProduct(product) {
    let products = JSON.parse(localStorage.getItem('products')) || [];
    products.push(product);
    localStorage.setItem('products', JSON.stringify(products));
}

function getProducts() {
    return JSON.parse(localStorage.getItem('products')) || [];
}

addProduct({ id: 3, name: 'Tablet' }.name);
console.log(getProducts());
```
  1. ['Tablet', 'Tablet']
  2. ['Tablet', 'Tablet', 'Tablet']
  3. [{ id: 3, name: 'Tablet' }]
  4. [undefined]
MAD2 Quiz 2 · 16 Aug 2026 · open the full paper
Practice 7MSQ3 marksselect all that apply
A Vue frontend, a mobile app, and another backend service all call the same Flask API deployed on multiple servers. The team chooses JWT authentication. Which of the following statements are correct?
  1. Each request can carry the token, so any server can validate it without storing a per-user session in memory.
  2. JWT is API-friendly because clients can send it using the header.
    text
    ```
    Authorization: Bearer <token>
    ```
  3. In Flask-JWT-Extended, can read the identity stored in the token.
    text
    ```
    get_jwt_identity()
    ```
  4. Session-based authentication is usually easier to scale across multiple servers because no shared storage is needed. The team should have chosen this.
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 8MSQ2 marksselect all that apply
Consider running the following in Browser console: question figure Which of the following statements are correct?
Text of the picture (copyable)
```javascript
console.log(typeof setTimeout)
console.log(typeof document)
```
  1. The first line prints .
    text
    "function"
  2. The second line prints .
    text
    "undefined"
  3. will work in Browser by default because V8 provides the DOM.
    text
    ```javascript
    document.querySelector()
    ```
  4. Different runtimes (browser, Node.js, etc.) can provide different APIs even if they use the same JavaScript engine.
MAD2 Quiz 1 · 19 Jul 2026 · open the full paper
Practice 9MSQ2 marksselect all that apply
Which of the following are advantages of component-based frontend frameworks like Vue.js?
  1. Code reusability
  2. Better maintainability
  3. Automatic SQL query optimization
  4. Easier UI management
MAD2 End Term · 10 May 2026 · open the full paper
Practice 10MSQ2 marksselect all that apply
In a Single Page Application (SPA), what are the benefits of client-side routing over server-side routing?
  1. Slower navigation between pages
  2. Reduced load on the backend server
  3. Better SEO performance by default
  4. Seamless page transitions without full reloads
MAD2 Quiz 2 · 12 Apr 2026 · open the full paper
Practice 11MCQ3 marks
You are building a login feature for a web application. The frontend sends the user’s email and password to the backend API. The backend validates credentials against a database. Which security issues exist in the code given below? Frontend: script.js question figure Backend: app.py question figure
Text of the picture (copyable)
```javascript
methods: {
  async login() {
    const response = await fetch('/login', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ email: this.email, password: this.password })
    });
    const data = await response.json();
    console.log(data.message);
  }
}
```
```python
@app.route('/login', methods=['POST'])
def login():
    email = request.json['email']
    password = request.json['password']
    query = f"SELECT * FROM users WHERE email = '{email}'" \
            f" AND password = '{password}'"
    result = db.execute(query)
    if result:
        return jsonify({"message": "Login successful"})
    return jsonify({"message": "Invalid credentials"})
```
  1. The SQL query is vulnerable to SQL injection attacks
  2. Passwords are stored and compared in plain text
  3. No authentication token (session/JWT) mechanism is implemented
  4. All of these.
MAD2 Quiz 2 · 12 Apr 2026 · open the full paper
Practice 12MSQ3 marksselect all that apply
Consider a scenario involving localStorage, Promise chains, and Vue lifecycle hooks: Scenario: A user authentication system where: On app initialization, the app checks localStorage for a stored user token• If a token exists, it validates the token asynchronously (via a Promise)• Based on validation, different UI components are rendered• The user navigates between different views• Code in mounted() hook: question figure Which of the following statements is/are CORRECT about this implementation?
Text of the picture (copyable)
```javascript
mounted() {
  const storedToken = localStorage.getItem('userToken');
  if (storedToken) {
    this.validateToken(storedToken)
      .then(user => {
        this.user = user;
        this.isAuthenticated = true;
      })
      .catch(err => {
        localStorage.removeItem('userToken');
        this.isAuthenticated = false;
      });
  }
}
```
  1. If the page is refreshed while the Promise is pending, the token will be lost because localStorage is cleared on refresh
  2. If token validation fails, the token is removed from storage, preventing automatic login on future page loads
  3. The isAuthenticated flag might be false even though a storedToken exists, until the Promise validation completes
  4. sessionStorage should be used instead of localStorage because user tokens should not persist across browser sessions
  5. If the user navigates to a different route while validation is pending, the Promise will still complete and update the user data
MAD2 Quiz 1 · 15 Mar 2026 · open the full paper
Practice 13MCQ3 marks
Consider the following JavaScript code: question figure The above code is initially loaded in the browser, and then the browser is refreshed two times. What will be the final output printed in the console?
Text of the picture (copyable)
```javascript
function addItemToCart(item) {
    let cart = JSON.parse(localStorage.getItem('cart')) || [];
    cart.push(item);
    localStorage.setItem('cart', JSON.stringify(cart));
}

function getCartItems() {
    return localStorage.getItem('cart') || [];
}

addItemToCart({ id: 1, name: 'Laptop' }.name);

console.log(getCartItems());
```
  1. text
    ```
    []
    ```
  2. text
    ```
    ['Laptop', 'Laptop', 'Laptop']
    ```
  3. text
    ```
    [{ id: 1, name: 'Laptop' }]
    ```
  4. text
    [undefined]
MAD2 Quiz 1 · 15 Mar 2026 · open the full paper
Practice 14MCQ2 marks
Which of the following best describes UI State (Ephemeral State) in frontend applications?
  1. It includes all data stored permanently in the database and is shared across users
  2. It represents the complete system data such as users, products, and transactions
  3. It refers to short-lived interface elements like loading indicators or selected tabs
  4. It handles complex application logic and long-term session management
MAD2 Quiz 1 · 15 Mar 2026 · open the full paper
Practice 15MCQ2 marks
Given that HTTP is stateless, which approach is commonly used to manage application state between the client and the server?
  1. Storing all state permanently in frontend memory across sessions
  2. Allowing the frontend to handle complex business logic and data storage
  3. Client or server maintaining state and explicitly exchanging it through requests
  4. Eliminating state entirely from web applications
MAD2 Quiz 1 · 15 Mar 2026 · open the full paper
Practice 16MCQ5 marks
Consider the following Vue app with html and javascript file given below: File: index.html question figure File: script.js question figure What will be rendered on the browser for the code setup given above ?
Text of the picture (copyable)
```html
<div id="app">
  <my-comp>
    <h3>Exploring Vue Js</h3>

    <slot v-slot:last>
      <h3>Learning App Dev 2</h3>
    </slot>
  </my-comp>
</div>
```
```javascript
const MyComp = {
  name: 'my-comp',
  props: ['tech'],
  template: `
    <div class="container">
      <slot name="complete">
        <h3>Learned DBMS</h3>
      </slot>

      <slot>
        Exploring Frontend
      </slot>

      <slot name="last"></slot>
    </div>
  `
};

const app = new Vue({
  el: '#app',
  components: {
    MyComp
  }
});
```
  1. question figure
    text
    Learned DBMS
    Exploring Backend
  2. question figure
    text
    Learned DBMS
    
    Exploring Vue Js
    
    This is Last Course
  3. question figure
    text
    Learned DBMS
    Exploring Vue Js
  4. None of these.
MAD2 End Term · 21 Dec 2025 · open the full paper
Practice 17MCQ3 marks
Consider the following JavaScript code snippet where a web application manages user preferences using localStorage. A user opens the application, sets their theme preference to "dark", refreshes the page once, closes the browser tab, and opens a new tab to reload the page. What will be the behavior of the theme preference? question figure
Text of the picture (copyable)
Code:
```javascript
const setTheme = (theme) => {
  localStorage.setItem('theme', theme);
  console.log('Theme set to:', theme);
};

const getTheme = () => {
  return localStorage.getItem('theme') || 'light';
};

setTheme('dark');
console.log(getTheme());
```
  1. The theme will be lost because closing the browser tab clears localStorage
  2. The theme will be preserved as "dark" because localStorage persists across browser sessions
  3. The theme will be undefined because localStorage is cleared on refresh
  4. The theme will be reset to "light" when a new tab is opened
MAD2 End Term · 21 Dec 2025 · open the full paper
Practice 18MCQ3 marks
A developer uses sessionStorage to store authentication tokens in a web application. The user logs in, the token is stored, and then they close the browser window completely. When they reopen the browser later, what will happen? Code: question figure
Text of the picture (copyable)
```javascript
const saveToken = (token) => {
  sessionStorage.setItem('authToken', token);
};

const getToken = () => {
  return sessionStorage.getItem('authToken') || null;
};
```
  1. The token will be preserved and available in the new browser session.
  2. The token will be cleared because sessionStorage is cleared when the browser is closed.
  3. The token will be partially available but require re-authentication.
  4. The token will move to localStorage automatically.
MAD2 End Term · 31 Aug 2025 · open the full paper
Practice 19MCQ2 marks
What does "reactivity" mean in the context of frontend frameworks like Vue.js?
  1. The component will reload when data changes
  2. All function calls become asynchronous
  3. It disables direct access to state
  4. The DOM updates automatically when the underlying reactive data changes
MAD2 End Term · 31 Aug 2025 · open the full paper
Practice 20MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code running in a browser:

```javascript
localStorage.setItem('score', '10');
sessionStorage.setItem('multiplier', '3');

for (let i = 0; i < 2; i++) {
    let score = localStorage.getItem('score');
    let multiplier = sessionStorage.getItem('multiplier');

    score = score + 5;
    multiplier = multiplier * 2;

    localStorage.setItem('score', score);
    sessionStorage.setItem('multiplier', multiplier);
}

console.log(localStorage.getItem('score'));
console.log(sessionStorage.getItem('multiplier'));
```

What will be the output in the browser console?
  1. question figure
    text
    20
    12
  2. question figure
    text
    20
    NaN
  3. question figure
    text
    NaN
    12
  4. question figure
    text
    None of these
MAD2 End Term · 31 Aug 2025 · open the full paper
Practice 21MCQ4.5 marks
question figure
Text of the picture (copyable)
Given the Flask app:

```python
from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
CORS(app, resources={r"/api/*": {"origins": "http://localhost:3000"}})

@app.route('/api/data')
def data():
    return {"msg": "Success"}
```

frontend code:

```javascript
fetch("http://localhost:5000/api/data")
    .then(res => res.json())
    .then(data => console.log(data));
```

What will happen when run from a Vue app hosted at http://localhost:5173?
  1. Request succeeds
  2. CORS error occurs
  3. 404 error
  4. The server crashes
MAD2 Quiz 2 · 03 Aug 2025 · open the full paper
Practice 22MSQ2 marksselect all that apply
Which of the following statement(s) about Web Storage APIs is/are correct?
  1. question figure
    text
    The `localStorage` object stores data with no expiration date, even after the browser is closed.
  2. question figure
    text
    The `sessionStorage` object keeps data only for the duration of the page session.
  3. question figure
    text
    Both `localStorage` and `sessionStorage` can store data in key-value pair format.
  4. question figure
    text
    Data stored in `sessionStorage` is available across different browser tabs.
MAD2 Quiz 2 · 03 Aug 2025 · open the full paper
Practice 23MSQ2 marksselect all that apply
Which of the following statement(s) is/are true regarding Single Page Applications (SPA) and Progressive Web Apps (PWA)?
  1. SPAs use client-side routing to dynamically update content without full pagereloads.
  2. PWAs can work offline using service workers.
  3. SPAs always require a server-side language to handle routing.
  4. PWAs can be added to a device’s home screen like native apps.
MAD2 Quiz 1 · 13 Jul 2025 · open the full paper
Practice 24MCQ2 marks
In Vue 2, what happens when you update a data property?
  1. DOM is immediately updated without virtual DOM
  2. The page reloads
  3. The virtual DOM detects changes and updates efficiently
  4. A full component re-renders from scratch
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 25MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below CORS enabled flask app.

```python
from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
CORS(app, resources={r"/api/*": {"origins": "http://localhost:5000"}})

@app.route("/api/data")
def data():
    return {"message": "Hello from Flask"}
```

If a Vue.js frontend (simulation given below) at "http://localhost:3000" tries to fetch data, what will happen?

```javascript
fetch("http://localhost:5000/api/data")
    .then(response => response.json())
    .then(data => console.log(data));
```
  1. The request will be blocked due to CORS policy.
  2. The request will succeed and return { "message": "Hello from Flask" }.
  3. The request will fail because Vue.js does not support CORS.
  4. The server will crash due to incorrect CORS settings.
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 26MCQ4.5 marks
Consider the following Vue apps in script.js and the index.html file. question figure Consider the following Vue apps in script.js and the index.html file. What will be rendered on the browser?
Text of the picture (copyable)
script.js
```javascript
const app1 = new Vue({
  el: '#app1',
  data: {
    value1: "VueJS",
    value2: "Frontend"
  }
})
const app2 = new Vue({
  el: '#app2',
  data: {
    value3: "JavaScript"
  }
})
```

index.html
```html
<div id="app2">
  {{value1}}
  <div id="app1">
    {{value2}}
  </div>
  {{value3}}
</div>
<script src="./script.js"></script>
```
  1. Frontend
  2. VueJSFrontend
  3. VueJSJavaScript
  4. FrontendJavaScript
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 27MCQ4.5 marks
Consider the following Vue App and the HTML document given below. question figure Consider the following Vue App and the HTML document given below. What will be the output on the browser?
Text of the picture (copyable)
index.html
```html
<div id="app">
    <my-comp>
        <slot>Hello Frontend</slot>
        <slot>Hello VueJS</slot>
    </my-comp>
</div>
<script src="script.js"></script>
```

script.js
```javascript
const myComp = {
    template: `
        <div>
            <slot></slot>
            <slot></slot>
        </div>
    `
}

const app = new Vue({
    components: {
        "my-comp": myComp
    }
}).$mount('#app')
```
  1. Hello Frontend Hello Frontend
  2. Hello VueJS Hello VueJS
  3. Hello Frontend Hello Vue JS
  4. Hello Frontend Hello Vue JS Hello Frontend Hello Vue JS
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 28MCQ3 marks
Comprehension passage for this question
Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions.
What will be rendered on the browser for the given value of localStorage? question figure What will be rendered on the browser for the given value of localStorage?
Text of the picture (copyable)
```
{
  token: 112,
  userRole: "manager"
}
```
  1. You are not logged in.
  2. Welcome to profile
  3. You are not authorized.
  4. None of these.
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 29MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code.

```javascript
export default {
  data() {
    return {
      loginToken: '',
    };
  },
  mounted() {
    this.loginToken = sessionStorage.getItem('authToken') || '';
  },
  methods: {
    updateToken(newToken) {
      this.loginToken = newToken;
      sessionStorage.setItem('authToken', newToken);
    }
  }
};
```

What will happen when a user calls the updateToken method with a new value and then refreshes the page?
  1. question figure
    text
    The new token will be lost, and the "loginToken" data property will be reset to an empty string.
  2. question figure
    text
    The new token will be preserved in session storage, and the "LoginToken" data property will be populated with the stored value on page refresh.
  3. question figure
    text
    The method will throw an error because sessionStorage cannot be modified directly.
  4. question figure
    text
    The "loginToken" data property will be updated, but the session storage will remain unchanged.
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 30MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below flask SSE implementation.

```python
from flask import Flask, Response
import time

app = Flask(__name__)

def event_stream():
    for i in range(5):
        yield f"data: Message {i}"
        time.sleep(1)

@app.route('/events')
def sse():
    return Response(event_stream(), mimetype="text/event-stream")
```

And the Vue.js frontend:

```html
<template>
  <div>
    <p v-for="msg in messages" :key="msg">{{ msg }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return { messages: [] };
  },
  mounted() {
    const eventSource = new EventSource("http://localhost:5000/events");
    eventSource.onmessage = (event) => {
      this.messages.push(event.data);
    };
  },
};
</script>
```

What will happen when a user opens this page?
  1. The client will receive 5 messages, one per second.
  2. The client will receive all 5 messages instantly.
  3. The client will not receive any messages due to CORS issues.
  4. The server will crash because Flask cannot handle SSE.
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 31MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue apps in script.js and the index.html file.

script.js

```javascript
const app1 = new Vue({
  el: '#app1',
  data: {
    value1: "VueJS",
    value2: "Frontend"
  }
})

const app2 = new Vue({
  el: '#app2',
  data: {
    value3: "JavaScript"
  }
})
```

index.html

```html
<div id="app2">
  {{value1}}
  <div id="app1">
    {{value2}}
  </div>
  {{value3}}
</div>
<script src="./script.js"></script>
```

What will be rendered on the browser?
  1. Frontend
  2. VueJSFrontend
  3. VueJSJavaScript
  4. FrontendJavaScript
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 32MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue App and the HTML document given below.

index.html
```html
<div id="app">
  <my-comp>
    <slot>Hello Frontend</slot>
    <slot>Hello VueJS</slot>
  </my-comp>
</div>
<script src="script.js"></script>
```

script.js
```javascript
const myComp = {
  template: `
    <div>
      <slot></slot>
      <slot></slot>
    </div>
  `
}

const app = new Vue({
  components: {
    "my-comp": myComp
  }
}).$mount('#app')
```

What will be the output on the browser?
  1. Hello Frontend Hello Frontend
  2. Hello VueJS Hello VueJS
  3. Hello Frontend Hello Vue JS
  4. Hello Frontend Hello Vue JS Hello Frontend Hello Vue JS
MAD2 End Term · 13 Apr 2025 · open the full paper
Practice 33MCQ3 marks
Comprehension passage for this question
Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions. question figure Consider the following Vue app with the Vue Router shown below and answer the given subquestions.
What will be rendered on the browser for the given value of localStorage? question figure What will be rendered on the browser for the given value of localStorage?
Text of the picture (copyable)
```json
{
  "token": 112,
  "userRole": "admin"
}
```
  1. You are not logged in.
  2. Welcome to profile
  3. You are not authorized.
  4. None of these.
MAD2 Quiz 2 · 16 Mar 2025 · open the full paper
Practice 34MCQ2 marks
question figure
Text of the picture (copyable)
What distinguishes a Progressive Web App (PWA) from a traditional web application?
  1. PWAs must be downloaded from an app store
  2. PWAs only work on mobile devices
  3. PWAs can work offline and be installed on the home screen
  4. PWAs require native mobile code
MAD2 Quiz 2 · 16 Mar 2025 · open the full paper
Practice 35MCQ4.5 marks
What will be the visited pages history when the user navigates between pages and refreshes the page? question figure
Text of the picture (copyable)
Consider the below Vue.js application.

```html
<template>
  <div>
    <button @click="goToPage('Home')">Go to Home</button>
    <button @click="goToPage('About')">Go to About</button>
    <button @click="goToPage('Contact')">Go to Contact</button>

    <div v-if="visitedPages.length">
      <h3>Visited Pages:</h3>
      <ul>
        <li v-for="(page, index) in visitedPages" :key="index">{{ page }}</li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visitedPages: []
    };
  },
  mounted() {
    const storedPages = JSON.parse(sessionStorage.getItem('visitedPages')) || [];
    this.visitedPages = storedPages;
  },
  methods: {
    goToPage(page) {
      this.visitedPages.push(page);
      sessionStorage.setItem('visitedPages',
        JSON.stringify(this.visitedPages));
      this.$router.push(`/${page.toLowerCase()}`);
    }
  }
};
</script>
```
  1. The list of visited pages will reset to empty after the page is refreshed.
  2. The list of visited pages will be updated with the current page after everynavigation and will not reset even after reload.
  3. The navigation history will not be stored in sessionStorage.
  4. All of these
MAD2 Quiz 2 · 16 Mar 2025 · open the full paper
Practice 36MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below Vue.js application.

```html
<template>
  <div>
    <input v-model="name" placeholder="Enter name">
    <input v-model="email" placeholder="Enter email">
    <button @click="submitForm">Submit</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: '',
      email: ''
    };
  },
  mounted() {
    if (localStorage.getItem('formData')) {
      const savedData = JSON.parse(localStorage.getItem('formData'));
      this.name = savedData.name;
      this.email = savedData.email;
    }
  },
  watch: {
    name(newVal) {
      localStorage.setItem('formData', JSON.stringify({ name: newVal, email: localStorage.email }));
    },
    email(newVal) {
      localStorage.setItem('formData', JSON.stringify({ name: localStorage.name, email: newVal }));
    }
  },
  methods: {
    submitForm() {
      localStorage.removeItem('formData');
      this.name = '';
      this.email = '';
    }
  }
};
</script>
```

What will happen if the user submits the form and reloads the page?
  1. The form data will persist in the input fields even after submission and pagereload.
  2. The form data will be cleared after submission, and no data will appear after apage reload.
  3. The form data will appear in the inputs after submission and page reload, butonly until the user starts typing again.
  4. The page will go blank.
MAD2 Quiz 1 · 23 Feb 2025 · open the full paper
Practice 37MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue2 app and the index file given below.

index.html

```html
<body>
    <div id="app">
        <h4>{{ state }}</h4>
    </div>
    <script
        src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"
    ></script>
    <script src="./script.js"></script>
</body>
</html>
```

script.js

```javascript
const app = new Vue({
    el: '#app',
    data: {
        terminal: ['3', '2', '1'],
        curr_status: ["arrived", "departed", "delayed"]
    },
    computed: {
        state: () => {
            return `The flight 103 has ${this.curr_status[1]} from terminal ${this.terminal[2]}.`
        }
    }
})
```

What will be the output on the browser?
  1. The flight 103 has departed from terminal 1.
  2. The flight 103 has arrived from terminal 2.
  3. The flight 103 has delayed from terminal 3.
  4. The flight 103 has from terminal.
  5. ReferenceError
MAD2 Quiz 1 · 23 Feb 2025 · open the full paper
Practice 38MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue App and the HTML document given below.

index.html
```html
<body>
    <div id="app">
        <my-comp>
            <h3>Exploring Vue JS</h3>
            <template v-slot:ongoing>
                <h3>Learning App Dev 2</h3>
            </template>
        </my-comp>
    </div>
    <script src="./script.js"></script>
</body>
```

script.js
```javascript
const MyComp = {
    name: 'my-comp',
    props: ['tech'],
    template: `<div class="container">
        <slot name="complete"><h3>Learned DBMS</h3></slot>
        <slot name="ongoing"></slot>
        <slot>Exploring Frontend</slot>
    </div>`
}

const app = new Vue({
    el: '#app',
    components: {
        MyComp
    }
})
```

What will be rendered on the browser for code setup given above?
  1. Learning App Dev 2Exploring Vue JS
  2. Learning App Dev 2Exploring Frontend
  3. Learned DBMSLearning App Dev 2 Exploring Frontend
  4. Learned DBMSLearning App Dev 2 Exploring Vue JS
MAD2 End Term · 22 Dec 2024 · open the full paper
Practice 39MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code.

```javascript
function addItemToCart(item) {
  let cart = JSON.parse(localStorage.getItem('cart')) || [];
  cart.push(item);
  localStorage.setItem('cart', JSON.stringify(cart));
}

function getCartItems() {
  return JSON.parse(localStorage.getItem('cart')) || [];
}

addItemToCart({ id: 1, name: 'Laptop' }.name);
console.log(getCartItems());
```

The above code is initially loaded on the browser and then the browser is refreshed two times.
What will be the final output?
  1. []
  2. ['Laptop', ‘Laptop’, ‘Laptop’]
  3. [{ id: 1, name: 'Laptop' }]
  4. [undefined]
MAD2 End Term · 22 Dec 2024 · open the full paper
Practice 40MCQ2 marks
Which of the following statements is FALSE?
  1. Cache-Control: no-store prevents caching
  2. ETag helps validate cache freshness
  3. Data stored in sessionStorage remains available even after the browser isclosed and reopened.
  4. localStorage has larger storage limit than cookies
MAD2 End Term · 22 Dec 2024 · open the full paper
Practice 41MCQ3 marks
question figure
Text of the picture (copyable)
Consider the below Vue component.

```javascript
export default {
  data() {
    return {
      userName: '',
    };
  },
  mounted() {
    this.userName = sessionStorage.getItem('userName') || '';
  },
  watch: {
    userName(newVal) {
      sessionStorage.setItem('userName', newVal);
    }
  }
};
```

What will happen when the user enters a new value for "userName" and refreshes the page?
  1. The new value will be stored in session storage, and the “userName” dataproperty will be updated.
  2. The new value will be stored in session storage, but the “userName” dataproperty will be reset to an empty string on page refresh.
  3. The “userName” data property will be reset to an empty string, and thesession storage value will be ignored on refresh.
  4. The “userName” data property will not be updated in session storage becausesession storage doesn't persist across refreshes.
MAD2 Quiz 2 · 01 Dec 2024 · open the full paper
Practice 42MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the below Vuex implementation.

```javascript
const store = new Vuex.Store({
  state: {
    token: sessionStorage.getItem('authToken') || null
  },
  mutations: {
    setToken(state, token) {
      state.token = token;
      sessionStorage.setItem('authToken', token);
    },
    clearToken(state) {
      state.token = null;
      sessionStorage.removeItem('authToken');
    }
  },
  actions: {
    login({ commit }, token) {
      commit('setToken', token);
    },
    logout({ commit }) {
      commit('clearToken');
    }
  }
});
```

After the user logs in with a token and refreshes the page, what will happen to the Vuex state and the session storage?
  1. The session storage will reset, but the Vuex state will still contain the“authToken”.
  2. Both the Vuex state and the sessionStorage will retain the token after the pagerefresh.
  3. The Vuex state will load the token from sessionStorage after the page refresh.
  4. The token will be lost from both the Vuex state and sessionStorage after thepage refresh.
MAD2 Quiz 2 · 01 Dec 2024 · open the full paper
Practice 43MSQ3 marksselect all that apply
question figure
Text of the picture (copyable)
Consider the below Vue component.

```html
<template>
  <div>
    <button @click="setDarkMode">Dark Mode</button>
    <button @click="setLightMode">Light Mode</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      theme: localStorage.getItem('theme') || 'light'
    };
  },
  methods: {
    setDarkMode() {
      this.theme = 'dark';
      localStorage.setItem('theme', 'dark');
    },
    setLightMode() {
      this.theme = 'light';
      localStorage.setItem('theme', 'light');
    }
  }
};
</script>
```

Which of the following statement(s) is/are correct about the behavior of the above component?
  1. The theme will persist across page reloads because it is stored in localStorage.
  2. If the user opens a new tab, the theme will reset to 'light' in that new tab.
  3. The theme will reset to 'light' every time the page is refreshed.
  4. The theme will be shared across all open tabs, as localStorage is accessibleacross tabs of the same origin.
MAD2 Quiz 1 · 27 Oct 2024 · open the full paper
Practice 44MSQ2 marksselect all that apply
Which of the following scenario(s) represent ephemeral state(s) in a web application?
  1. The user's current scroll position on a webpage.
  2. The user's authentication token, saved in localStorage.
  3. The temporary state of a dropdown menu.
  4. All of these
MAD2 End Term · 01 Sep 2024 · open the full paper
Practice 45MCQ3 marks
question figure
Text of the picture (copyable)
Consider the following JavaScript code snippet.

```javascript
// Code Snippet 1
sessionStorage.setItem('username', 'course_user');
let storedUsername = sessionStorage.getItem('username');

// Code Snippet 2
sessionStorage.removeItem('username');
let removedUsername = sessionStorage.getItem('username');

// Code Snippet 3
sessionStorage.clear();
let clearedStorage = sessionStorage.username;
```

What will be the values of 'storedUsername', 'removedUsername', and 'clearedStorage' after the execution of the above code snippets?
  1. storedUsername: 'course_user', removedUsername: null, clearedStorage: null
  2. storedUsername: 'course_user', removedUsername: undefined,clearedStorage: null
  3. storedUsername: 'course_user', removedUsername: null, clearedStorage:undefined
  4. storedUsername: 'course_user', removedUsername: undefined,clearedStorage: undefined
MAD2 End Term · 01 Sep 2024 · open the full paper
Practice 46MCQ4.5 marks
Consider the following Vue.js 2 component using CDN. question figure Consider the following Vue.js 2 component using CDN. After entering "Orange" in the input box and clicking the "Add" button, what will be seen in the browser?
Text of the picture (copyable)
```html
<div id="app">
  <input v-model="newItem" placeholder="Add an item" />
  <button @click="addItem">Add</button>

  <ul>
    <li v-for="(item, index) in items" :key="index">
      {{ index + 1 }}. {{ item }}
    </li>
  </ul>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      newItem: '',
      items: ['Apple', 'Banana']
    },
    methods: {
      addItem() {
        if (this.newItem) {
          this.items.push(this.newItem, this.newItem);
          this.newItem = '';
        }
      }
    }
  });
</script>
```
  1. 1. Apple2. Banana 3. Orange 4. Orange
  2. 1. Apple2. Banana 3. Orange
  3. 1. Apple2. Banana 3. Orange 3. Orange
  4. 1. Apple2. Banana
MAD2 End Term · 01 Sep 2024 · open the full paper
Practice 47MCQ4.5 marks
Consider the following javascript code running on browser question figure Consider the following javascript code running on browser What will be the output in the browser console?
Text of the picture (copyable)
```javascript
localStorage.setItem('counter', '0');
sessionStorage.setItem('total', '5');

for (let i = 0; i < 3; i++) {
    let counter = localStorage.getItem('counter');
    let total = sessionStorage.getItem('total');

    counter += 2;
    total *= 2;

    localStorage.setItem('counter', counter);
    sessionStorage.setItem('total', total);
}

sessionStorage.clear();

console.log(localStorage.getItem('counter'));
console.log(sessionStorage.getItem('total'));
```
  1. 640
  2. null40
  3. 6null
  4. 0222null
MAD2 End Term · 01 Sep 2024 · open the full paper
Practice 48MCQ4.5 marks
In a Vue CLI project with Vuex, you have the following configuration: question figure In a Vue CLI project with Vuex, you have the following configuration: question figure In a Vue CLI project with Vuex, you have the following configuration:
Text of the picture (copyable)
src/store/index.js:
```javascript
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    value: "",
  },
  mutations: {
    setValue(state, payload) {
      state.value = payload;
    }
  },
  actions: {
    async fetchValue({ commit }) {
      // Simulate async API call
      const response = await new Promise(resolve => setTimeout(() => 
        resolve('API Value'), 500));
      commit('setValue', response);
    }
  }
});
```
src/App.vue:
```html
<template>
  <div>
    <p>{{ value }}</p>
    <button @click="updateValue">Update Value</button>
  </div>
</template>

<script>
export default {
  computed: {
    value() {
      return this.$store.state.value;
    },
  },
  methods: {
    async updateValue() {
      await this.$store.dispatch('fetchValue');
    },
  },
};
</script>
```
After running "npm run serve", if you click the "Update Value" button, what will be displayed in the `<p>` tag?
  1. question figure
    text
    API Value
  2. question figure
    text
    "" ""
  3. question figure
    text
    undefined
  4. question figure
    text
    null
MAD2 Quiz 2 · 04 Aug 2024 · open the full paper
Practice 49MCQ3 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">
    <input v-model = "phrase" @input = "compute_marks">
    <p>{{marks}}</p>
</div>
<script scr = "app.js"></script>
```

app.js:

```javascript
new Vue({
    el : "#app",
    data : {
        phrase : "AppDev",
        marks : 50,
    },

    mounted() {
        this.phrase = "Bravo";
        this.marks = 50;

        if (localStorage.marks) {
            this.phrase += "2";
            this.marks = parseInt(localStorage.marks) + 20;
        }
        else {
            this.phrase += "1";
            this.marks += 10;
        }
    },

    methods : {
        compute_marks() {
            localStorage.setItem("phrase", this.phrase);
            localStorage.setItem("marks", this.marks + 10);
        }
    }
})
```

Suppose you open "index.html" file in a browser, and type the text "Hurray" in the text box shown (after removing the previous text, if any), and hard refresh the page 7 times, without clicking anywhere. What will be the value shown in the text box, and the "marks" placeholder, respectively?

Tip: The "oninput" event occurs immediately after the value of an element has changed.
  1. Bravo1, 70
  2. Bravo2, 90
  3. Bravo1, 60
  4. Bravo2, 70
  5. Bravo1, 80
MAD2 Quiz 1 · 07 Jul 2024 · open the full paper
Practice 50MCQ4.5 marks
question figure
Text of the picture (copyable)
Consider the following Vue application with markup index.html and JavaScript file app.js.
File: index.html

```html
<div id = "app">
    <div>Welcome to Frontend Development</div>
    <new>Vue is a Frontend Framework</new>
</div>
<script src="script.js"></script>
```

File: script.js

```javascript
Vue.component('new', {
    template : `<div>
        <slot>Vue is JS Framework</slot>
        <div>Learn Vue 2 and Vue 3</div>
    </div>`
});

new Vue({
    el : "#app",
})
```

What will be rendered on the browser screen?
  1. question figure
    text
    Welcome to Frontend Development
    Vue is a JS Framework
    Vue is a Frontend Framework
    Learn Vue 2 and Vue 3
  2. question figure
    text
    Welcome to Frontend Development
    Vue is a Frontend Framework
    Vue is a JS Framework
    Learn Vue 2 and Vue 3
  3. question figure
    text
    Welcome to Frontend Development
    Vue is a Frontend Framework
    Learn Vue 2 and Vue 3
  4. question figure
    text
    Welcome to Frontend Development
    Vue is a JS Framework
    Learn Vue 2 and Vue 3
MAD2 End Term · 28 Apr 2024 · open the full paper
Practice 51MCQ4.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
<div id = "app">
  <input v-model = "subject" @input = "compute_marks">
  <p> {{marks}} </p>
</div>
<script scr = "app.js"></script>
```

app.js:

```javascript
new Vue({
  el : "#app",
  data : {
    subject : "AppDev",
    marks : 50,
  },

  mounted () {
    this.subject = "AppDev";
    this.marks = 50;
    if (localStorage.marks) {
      this.subject += "1";
      this.marks = parseInt(localStorage.marks) + 20;
      localStorage.marks = this.marks;
      localStorage.subject = this.subject;
    }
    else {
      this.subject += "2";
      this.marks += 20;
    }
  },

  methods : {
    compute_marks() {
      localStorage.setItem("subject", this.subject);
      localStorage.setItem("marks", this.marks + 10);
    }
  }
})
```

Suppose you open "index.html" file in a browser, and type the text "EndTermExam" in the text box shown (after removing the previous text, if any), and hard refresh the page thrice, without clicking anywhere. What will be the value shown in the text box, and the "marks" placeholder, respectively?
  1. AppDev1, 120
  2. AppDev2, 120
  3. AppDev1, 140
  4. AppDev2, 140
MAD2 Quiz 2 · 24 Mar 2024 · open the full paper
Practice 52MCQ2 marks
Consider the following JavaScript code snippet. question figure Consider the following JavaScript code snippet. What will be the values of 'storedUsername', 'removedUsername', and 'clearedStorage' after the execution of the above code snippets?
Text of the picture (copyable)
```javascript
// Code Snippet 1
sessionStorage.setItem('username', 'course_user');
let storedUsername = sessionStorage.getItem('username');

// Code Snippet 2
sessionStorage.removeItem('username');
let removedUsername = sessionStorage.getItem('username');

// Code Snippet 3
sessionStorage.clear();
let clearedStorage = sessionStorage.username;
```
  1. question figure
    text
    ```
    storedUsername: 'course_user', removedUsername: null, clearedStorage: null
    ```
  2. question figure
    text
    ```
    storedUsername: 'course_user', removedUsername: null, clearedStorage:
    undefined
    ```
  3. question figure
    text
    ```
    storedUsername: 'course_user', removedUsername: undefined, clearedStorage:
    null
    ```
  4. question figure
    text
    ```
    storedUsername: 'course_user', removedUsername: undefined, clearedStorage:
    undefined
    ```
MAD2 Quiz 2 · 24 Mar 2024 · open the full paper
Practice 53MCQ4.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”. Suppose you open “index.html” file in a browser, and type the text “App Dev” 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?
Text of the picture (copyable)
index.html:
```html
<div id = "app">
    <input v-model = "course" @input = "do_something">
    <p> {{role}} </p>
</div>
```
app.js:
```javascript
new Vue({
    el : "#app",
    data : {
        course : "#app",
        role : "user",
    },

    mounted () {
        try {
            this.course = localStorage.getItem("course").split(" ")[0];
            this.role = localStorage.getItem("course").split(" ")[1];
            localStorage.setItem("course",
                localStorage.getItem("course").split(" ")[0] + " " +
                this.course);
        }
        catch {
            this.course = "MAD_II";
            this.role = "admin";
        }
    },

    methods : {
        do_something() {
            localStorage.setItem("course", this.course);
            localStorage.setItem("role", this.role);
        }
    }
})
```
  1. MAD_II, admin
  2. App, Dev
  3. App, App
  4. Dev, App
MAD2 Quiz 2 · 24 Mar 2024 · open the full paper
Practice 54MSQ2 marksselect all that apply
Which of the following statement(s) is/are correct regarding web storage APIs?
  1. Web Storage APIs provide a way to store key-value pairs persistently on theclient side.
  2. Web Storage APIs include “localStorage” and “sessionStorage”.
  3. Data stored in “localStorage” is automatically cleared when the browsersession ends.
  4. The “sessionStorage” allows data to persist across browser sessions.
MAD2 Quiz 2 · 24 Mar 2024 · open the full paper
Practice 55MSQ4.5 marksselect all that apply
Consider the below application with markup “index.html” and JavaScript file “app.js”. question figure Consider the below application with markup “index.html” and JavaScript file “app.js”. Suppose the application is running on “http://127.0.0.1:8080”, select the correct option(s)?
Text of the picture (copyable)
Filename: index.html
```html
<body>
    <div id="app"></div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
    <script src="app.js"></script>
</body>
```

Filename: app.js
```javascript
const records = {
    1: {albums: "Heartrisers", songs: 20, genre: 4},
    2: {albums: "Pianobind", songs: 13, genre: 5}
}

const notFound = { template: `<h1>Unknown record!</h1>` }
const myRecords = {
    template: `<h1>{{record.albums}} has {{record.songs}} songs across
    {{record.genre}} genres.</h1>`,

    data() {
        return {record: records[this.$route.params.id]}
    },
}

const router = new VueRouter({
    routes: [
        { path: '/records/:id', component: myRecords },
        { path: '*', component: notFound },
    ],
})

new Vue({
    el: '#app',
    template: '<div><router-view /></router-view></div>',
    router,
})
```
  1. question figure
    text
    For the endpoint, http://127.0.0.1:8080/records/1, The browser will render:
    **Heartrisers has 20 songs across 4 genres.**
  2. question figure
    text
    For the endpoint, http://127.0.0.1:8080/#/records/2, The browser will render:
    **Pianobind has 13 songs across 5 genres.**
  3. question figure
    text
    For the endpoint, http://127.0.0.1:8080/#/records, The browser will render:
    **Unknown record!**
  4. question figure
    text
    For the endpoint, http://127.0.0.1:8080/#/records/3, The browser will render:
    **Unknown record!**
MAD2 Quiz 1 · 25 Feb 2024 · open the full paper
Practice 56MCQ3 marks
question figure
Text of the picture (copyable)
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. question figure
    text
    Not Matched
  2. question figure
    text
    Matched
  3. question figure
    text
    undefined
  4. question figure
    text
    null
MAD2 Quiz 1 · 16 Jul 2023 · open the full paper
Practice 57MCQ4.5 marks
Consider the below Vue application with markup file “index.html”, and JavaScript file “app.js”. question figure Consider the below Vue application with markup file “index.html”, and JavaScript file “app.js”. question figure Consider the below Vue application with markup file “index.html”, and JavaScript file “app.js”.
Text of the picture (copyable)
```javascript
app.js
new Vue({
  el: '#app',
  template: `<div> The nearest city to you is: {{minDistance}}
</div>`,
  data: {
    userCoordinate: [1, 2],
    allCooridates: [
      { name: 'City1', coodinate: [1, 7] },
      { name: 'City2', coodinate: [2, 4] },
      { name: 'City3', coodinate: [3, 5] },
      { name: 'City4', coodinate: [1, 4] },
    ],
  },
  methods: {
    calculateDistance(x, y) {
      return Math.abs(x[0] - y[0]) + Math.abs(x[1] - y[1])
    },
  },
  computed: {
    minDistance() {
      let minDist = Infinity
      let city = null
      this.allCooridates.forEach((cord) => {
        let d = this.calculateDistance(cord.coodinate,
          this.userCoordinate)
        if (d < minDist) {
          minDist = d
          city = cord.name
        }
      })
      return city
    },
  },
})
```
index.html
```html
<div id="app"></div>
<script
  src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="./app.js"></script>
```
Suppose the application is running on http://localhost:8080.
What will be rendered by the browser?
  1. The nearest city to you is: City1
  2. The nearest city to you is: City2
  3. The nearest city to you is: City3
  4. The nearest city to you is: City4
MAD2 End Term · 30 Apr 2023 · open the full paper
Practice 58MSQ2 marksselect all that apply
Which of the following statement(s) is/are false regarding javascript language?
  1. Hoisting moves the declaration of arrow functions to the top of their scopes.
  2. All 3 keywords, i.e., “var”, “let” and “const” can be used to declare globalvariables.
  3. The functions are treated as first class citizens in the language.
  4. Node.js is an example of a javascript engine.
MAD2 End Term · 30 Apr 2023 · open the full paper
Practice 59MCQ3 marks
Consider the below application with markup “index.html” and javascript file “app.js”. question figure Consider the below application with markup “index.html” and javascript file “app.js”.
Text of the picture (copyable)
index.html:
```html
<div id="app"></div>
<script
  src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
  src="https://unpkg.com/vue-router@3.0.0/dist/vue-router.js"></script>
<script src="app.js" type="module"></script>
```

app.js:
```javascript
const data = {
  1: { totalRun: 1000, totalMatches: 20 },
  2: { totalRun: 7000, totalMatches: 100 },
}
const NotFound = { template: '<div> Player Not Found</div>' }
const Profile = {
  template: `<div>Run: {{ {stat.totalRun}}, Matches:
{{stat.totalMatches}}, Average: {{average}}</div>`,
  data() {
    return {
      stat: data[this.$route.params.id],
    }
  },
  computed: {
    average() {
      return this.stat.totalRun / this.stat.totalMatches
    },
  },
}
const router = new VueRouter({
  routes: [
    { path: '/profile/:id', component: Profile },
    { path: '*', component: NotFound },
  ],
})
new Vue({
  el: '#app',
  template: '<div><router-view /></div>',
  router,
})
```

Suppose the application is running on "http://127.0.0.1:8080". What will be rendered inside the "router-view" component for the URL "http://127.0.0.1:8080/#/player"?
  1. Player Not Found
  2. Run: 1000, Matches: 20, Average: 50
  3. Run: 7000, Matches: 100, Average: 70
  4. None of these
MAD2 End Term · 30 Apr 2023 · open the full paper
Practice 60MCQ2 marks
Which of the following statements is false about VueJS framework?
  1. VueJS is a framework built on top of HTML, CSS and javascript.
  2. VueJS is built on a component based architecture.
  3. It cannot be installed/used via npm (node package manager).
  4. All of these