MAD Study Hub

Home / Past papers / MAD2 End Term / this paper

Modern Application Development Ii 18 Dec 25 - 21 Dec 2025

MAD2 End Term32 questions100 marks27 MCQ · 5 MSQ
Elapsed 00:00
Q1MCQ4 marks
Consider the following JavaScript code snippet: question figure What will be the output of the above program?
Text of the picture (copyable)
```javascript
const calculator = {
    multiplier: 5,
    calculate: function(a, b) {
        console.log(`Result: ${(a + b) * this.multiplier}`);
        return (a + b) * this.multiplier;
    }
};

const advancedCalc = {
    multiplier: 10,
    bonus: 20
};

const operation1 = calculator.calculate.call(advancedCalc, 3, 5);
const operation2 = calculator.calculate.bind(advancedCalc, 4);
operation2(8);
console.log(operation1);
console.log(typeof operation2);
```
  1. question figure
    text
    ```text
    Result: 40
    Result: 60
    40
    object
    ```
  2. question figure
    text
    ```
    Result: 80
    Result: 120
    80
    object
    ```
  3. question figure
    text
    ```
    Result: 40
    Result: 60
    40
    function
    ```
  4. question figure
    text
    ```text
    Result: 80
    Result: 120
    80
    function
    ```
Q2MSQ2 marksselect all that apply
Considering the following code snippet, which statements are true about components in Vue? question figure
Text of the picture (copyable)
```
childComponent.$emit('update', 5)
```
  1. Parent can listen with @update
  2. Parent receives payload via $event
  3. Child can directly modify parent state
  4. $emit triggers a DOM event
Q3MCQ3 marks
Consider the following JavaScript code snippet. question figure What will be printed on the console?
Text of the picture (copyable)
```javascript
Promise.resolve(1)
  .then(v => { throw v + 1 })
  .catch(e => e * 2)
  .then(console.log)
```
  1. 2
  2. 4
  3. Undefined
  4. Error
Q4MCQ2 marks
Which of the following is considered a good practice for securing user authentication in a web application?
  1. Storing passwords as plain text in the database for quick lookup
  2. Using hashing algorithms like "bcrypt" or "Argon2" to store passwords securely
  3. Including user passwords directly in SQL queries for verification
  4. All of these
Q5MCQ2 marks
In the following code snippet, which values should replace option1 and option2 so that the cookie is sent only over HTTPS and is restricted from cross-site requests? question figure
Text of the picture (copyable)
```python
response.set_cookie('session_id', 'abc123', secure=option1,
samesite=option2)
```
  1. secure=True and samesite='Strict'
  2. secure=False and samesite='Strict'
  3. secure=True and samesite='None'
  4. secure=False and samesite='Lax'
Q6MCQ3 marks
You are working in VS Code terminal with Git CLI. You are currently on branch appdev2, and you want to merge the latest changes from the main branch into appdev2. Which of the following command sequences correctly performs the merge with a commit?
  1. question figure
    text
    ```
    git checkout main
    git merge appdev2
    git commit -m "Merged main into appdev2"
    ```
  2. question figure
    text
    ```
    git merge main
    git commit -m "Merged main into appdev2"
    ```
  3. question figure
    text
    ```
    git checkout appdev2
    git pull origin main
    git commit -m "Pulled changes from main into appdev2"
    ```
  4. question figure
    text
    ```
    git merge appdev2 main
    git commit -m "Merged main into appdev2"
    ```
Q7MCQ3 marks
When comparing Redis with a typical API data store (like a relational database accessed through REST APIs), which of the following statements is true?
  1. Redis can only store strings, unlike API data stores which can handle complex structures.
  2. Redis is an in-memory data structure store, often used as a cache or message broker to complement API-based data stores.
  3. Redis is a relational database and queries data using SQL, just like an API data store.
  4. Redis is slower than API-based databases because it stores everything in memory.
Q8MCQ3 marks
How can you stop a Cross-Site Scripting (XSS) attack?
  1. Backend validation of user input and make sure any user-provided text is not executed as code.
  2. Store authentication token or jwt in cookies.
  3. Use v-html to show user generated data.
  4. Send cookies with every request to the backend.
Q9MSQ2 marksselect all that apply
Which of the following describe Redis features correctly?
  1. In-memory database
  2. Can support publish-subscribe (pub/sub)
  3. Can be used as Celery result backend
  4. Requires SQL to query
Q10MCQ2 marks
Which of the following is true about Vuex state?
  1. It should be modified only through mutations
  2. It should be modified only through actions
  3. It cannot contain nested objects
  4. It should be modified by getters
Q11MCQ2 marks
What is the purpose of Redis in a Celery-based system?
  1. To automatically retry failed tasks
  2. To execute tasks in parallel
  3. To return computed results in JSON format
  4. To store scheduled tasks and serve as a message broker
Q12MCQ3 marks
What happens to the fetch call when it gets a 404 status code (page not found)?
  1. text
    Promise rejects automatically
  2. text
    Promise resolves and `response.ok = true`
  3. text
    Promise resolves and `response.ok = false`
  4. text
    Promise stays as pending
Q13MCQ4 marks
Consider the following JavaScript code. question figure What will be the output?
Text of the picture (copyable)
```javascript
const p = Promise.resolve(1)
  .then(v => { console.log("A", v); return v + 1; })
  .then(v => { console.log("B", v); throw "err"; })
  .catch(e => { console.log("C", e); return 10; })
  .then(v => console.log("D", v)));

console.log("END");
```
  1. question figure
    text
    ```
    END
    A 1
    B 2
    C err
    D 10
    ```
  2. question figure
    text
    ```
    A 1
    B 2
    END
    C err
    D 10
    ```
  3. question figure
    text
    ```
    END
    A 1
    C err
    D 10
    ```
  4. question figure
    text
    ```
    END
    A 1
    B 2
    C err
    ```
Q14MCQ3 marks
Consider the following JavaScript snippet. question figure What will be printed on the browser's console?
Text of the picture (copyable)
```javascript
let arr = [1, 2, 3];
let result = arr.map(x => x * 2).filter(x => x > 4);
console.log(result);
```
  1. [2, 4, 6]
  2. [6]
  3. [4, 6]
  4. [1, 2, 3]
Q15MCQ3 marks
Consider the following JavaScript snippet: question figure What will be printed on the browsers' console?
Text of the picture (copyable)
```javascript
const obj = {
  x: 50,
  getX() { return this.x; }
};
const fn = obj.getX.bind({ x: 7 });
console.log(fn());
```
  1. 50
  2. undefined
  3. Error
  4. 7
Q16MCQ4 marks
Consider the following Vue Router setup and HTML. question figure Suppose the webpage is served at http://127.0.0.1:5000. A user visits the URL http://127.0.0.1:5000/#/user/10/orders. What will be rendered on the browser?
Text of the picture (copyable)
```javascript
const User = {
  template: `
    <div>
      <h2>User {{ $route.params.id }}</h2>
      <router-view></router-view>
    </div>
  `
};

const Overview = {
  template: `<p>User Overview</p>`
};

const Orders = {
  template: `<p>User Orders</p>`
};

const routes = [
  {
    path: "/user/:id",
    component: User,
    children: [
      { path: "", component: Overview },
      { path: "orders", component: Orders }
    ]
  }
];

const router = new VueRouter({ routes });
```

```html
<!-- html -->
<div id="app">
  <router-view></router-view>
</div>
```
  1. User Orders
  2. User 10 User Overview
  3. User 10 User Orders
  4. Nothing is rendered because sibling routes overwrite the parent route.
Q17MCQ3 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
Q18MCQ2 marks
A developer creates a Vue component using both v-if and v-show directives on different elements with initially false conditions. Later, the conditions are changed to true. What is the key difference in how these two directives handle the DOM?
  1. v-if removes the element from DOM when false, v-show only changes CSS display property
  2. v-show removes the element from DOM when false, v-if only changes CSS display property
  3. Both v-if and v-show re-mount the element and re-run lifecycle hooks
  4. Both directives are identical in their functionality; they just have different naming conventions
Q19MCQ3 marks
A Promise chain is created as follows. The first Promise resolves with a string, which is then processed through multiple .then() handlers. What will be logged to the console? question figure
Text of the picture (copyable)
```javascript
const processString = (str) => {
  return new Promise((resolve) => {
    setTimeout(() => resolve(str.toUpperCase()), 100);
  });
};

Promise.resolve('hello')
  .then(processString)
  .then(result => result + ' WORLD')
  .then(console.log)
  .catch(err => console.log('Error:', err));
```
  1. hello
  2. hello WORLD
  3. HELLO WORLD
  4. An error will be thrown
Q20MCQ3 marks
A JavaScript object is created and then assigned to another variable. Modifications are made through both variables. What will be the final state of the original object? question figure
Text of the picture (copyable)
Code:
```javascript
let originalConfig = { apiUrl: 'https://api.example.com', timeout: 5000 };
let configCopy = originalConfig;
configCopy.timeout = 10000;
configCopy = { apiUrl: 'https://api2.example.com', timeout: 3000 };
console.log(originalConfig.timeout);
```
  1. 5000
  2. 3000
  3. 10000
  4. undefined
Q21MSQ2 marksselect all that apply
Which of the following statements about the "this" keyword in JavaScript are correct?
  1. In a regular function, "this" is always bound to the global object (window in browsers)
  2. In an arrow function, "this" is inherited from the enclosing lexical scope
  3. The .call() method can be used to explicitly set the context of "this" in a function
  4. In a method called on an object, "this" always refers to that object regardless of how the function is defined
Q22MCQ3 marks
A Vue Router application uses lazy-loaded route components. When a user navigates to a route with a dynamic parameter (e.g., /product/:id), and the computed property depends on this route parameter, what could be a potential issue if the component is not properly handling asynchronous operations?
  1. The component will throw a critical error and crash the application
  2. The computed property will return undefined because the component hasn't mounted yet
  3. The route parameter will not be accessible in the computed property
  4. The component will display data from the previously loaded route
Q23MCQ3 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.
Q24MCQ5 marks
A developer creates a Vue component with prototype chain inspection. The component uses class-based inheritance with lifecycle hooks. Consider the following scenario. Code: question figure What will be the output on the browser's console?
Text of the picture (copyable)
```javascript
class BaseComponent {
  constructor(name) {
    this.name = name;
  }
}

class AdvancedComponent extends BaseComponent {
  constructor(name, role) {
    super(name);
    this.role = role;
  }
}

const comp = new AdvancedComponent('Alice', 'admin');
console.log(comp.__proto__ === AdvancedComponent.prototype);
console.log(comp.__proto__.__proto__ === BaseComponent.prototype);
console.log(comp instanceof BaseComponent);
console.log(comp instanceof AdvancedComponent);
```
  1. true true true true
  2. true false true true
  3. false true true false
  4. true true false false
Q25MSQ3 marksselect all that apply
In a web application using webhooks and Redis for real-time data synchronization: Scenario: An order management system where: • When an order is created, a webhook is sent to a notification service • Redis stores the current order cache • Multiple concurrent requests update the cache Which statements about this architecture are true?
  1. Webhooks guarantee that the notification service will process events in the exact order they were triggered
  2. Redis is suitable for this use case because it's an in-memory data structure store that provides fast access to cached data
  3. The webhook will automatically retry if the notification service is temporarily unavailable
  4. Webhooks use HTTP POST requests to communicate events asynchronously
Comprehension passage - the questions below it refer to this
Consider the Vue application. question figure Based on the above data, answer the given subquestions.
Q26MCQ3 marks
What happens when the user clicks the calculate button?
  1. expensive() runs again because the DOM updates
  2. expensive() does NOT run again because its dependencies did not change
  3. Vue recomputes all computed properties on any state change
  4. Nothing is displayed
Q27MCQ3 marks
Under which condition will the computed property expensive() re-run?
  1. When this.time changes
  2. The user clicks anywhere on the DOM
  3. Either this.a or this.b changes
  4. When Date.now() changes
Q28MSQ3 marksselect all that apply
What are the benefits of computed caching in Vue?
  1. Reduced CPU usage
  2. Faster rendering
  3. Avoids unnecessary recomputation
  4. Makes all computations asynchronous
Comprehension passage - the questions below it refer to this
Consider the following Vue 2 (CDN) code. html code: question figure script: question figure Based on the above data, answer the given subquestions.
Q29MCQ5 marks
What happens when the user clicks on "User 2" after initially opening "User 1"?
  1. text
    The route changes to /user/2 but the userId in data does not update.
  2. text
    The watcher updates `userId` to "2", and the `<p>` displays it instantly.
  3. text
    The `router-view` still shows User 1 because watchers don't re-render components.
  4. text
    An error occurs because `$route.params.id` cannot be watched.
Q30MCQ5 marks
Why is the watcher on $route.params.id necessary in this code?
  1. Without it, the userId in data would never change when the route changes.
  2. It is required because Vue Router does not automatically update component data.
  3. It prevents the component from being destroyed and recreated on every navigation.
  4. Both Without it, the userId in data would never change when the route changes and It is required because Vue Router does not automatically update component data are correct.
Comprehension passage - the questions below it refer to this
Consider the following Vue.js application with two different route scenarios and a component that uses reactive data binding: Scenario: An e-commerce application where: • Product list component displays products filtered by category • Category changes through router parameters: /products/:category • When a user navigates from /products/electronics to /products/books, the product list should update question figure Based on the above data, answer the given subquestions.
Q31MCQ5 marks
What will be rendered when the user first navigates to /products/electronics?
  1. An empty array because displayedProducts is initialized as null
  2. All three products because the watch handler hasn't been triggered yet
  3. Only the Laptop and Phone (both electronics)
  4. The data will show an error because the category doesn't exist in the array
Q32MCQ4 marks
When the user navigates from /products/electronics to /products/books, what will happen and why?
  1. The computed property will not update because it's being used in a watch handler
  2. The computed property will automatically re-evaluate because the route parameter dependency changed
  3. The displayedProducts variable will update, but the computed property will display stale data
  4. Both the computed property and displayedProducts will update to show books

Answer key

  1. Q1 (MCQ, 4 marks): D
  2. Q2 (MSQ, 2 marks): A, B
  3. Q3 (MCQ, 3 marks): B
  4. Q4 (MCQ, 2 marks): B
  5. Q5 (MCQ, 2 marks): A
  6. Q6 (MCQ, 3 marks): B
  7. Q7 (MCQ, 3 marks): B
  8. Q8 (MCQ, 3 marks): A
  9. Q9 (MSQ, 2 marks): A, B, C
  10. Q10 (MCQ, 2 marks): A
  11. Q11 (MCQ, 2 marks): D
  12. Q12 (MCQ, 3 marks): C
  13. Q13 (MCQ, 4 marks): A
  14. Q14 (MCQ, 3 marks): B
  15. Q15 (MCQ, 3 marks): D
  16. Q16 (MCQ, 4 marks): C
  17. Q17 (MCQ, 3 marks): B
  18. Q18 (MCQ, 2 marks): A
  19. Q19 (MCQ, 3 marks): C
  20. Q20 (MCQ, 3 marks): C
  21. Q21 (MSQ, 2 marks): B, C
  22. Q22 (MCQ, 3 marks): D
  23. Q23 (MCQ, 3 marks): B
  24. Q24 (MCQ, 5 marks): A
  25. Q25 (MSQ, 3 marks): B, D
  26. Q26 (MCQ, 3 marks): B
  27. Q27 (MCQ, 3 marks): C
  28. Q28 (MSQ, 3 marks): A, B, C
  29. Q29 (MCQ, 5 marks): B
  30. Q30 (MCQ, 5 marks): D
  31. Q31 (MCQ, 5 marks): C
  32. Q32 (MCQ, 4 marks): B