Home / Past papers / MAD2 End Term / this paper
. Which of the following best explains the relationship between the header and the signature in JWT authentication?``` header.payload.signature ```
, Celery Beat manages both the schedule and the execution, so running the Worker is redundant.``` beat_schedule ```
from the Flask app.``` .delay() ```
instead of inside
.In that case, Beat handles execution too.``` .apply_async() ``` ``` beat_schedule ```
and JavaScript
for a Vue application: File: index.html
File: app.js
Suppose the application is running on
, and the user visits the URL:
What will be rendered by the browser? [NOTE:
is divided in two images, consider them as one file content.]

index.html
app.js
```html
<div id="app">
<router-view></router-view>
</div>
```
```javascript
const Flights = {
template: `<h2>{{ result }}</h2>`,
data() {
return {
routes: [
{ city: "Delhi", connectedTo: ["Mumbai", "Pune"] },
{ city: "Indore", connectedTo: ["Bhopal", "Jaipur"] },
{ city: "Raipur", connectedTo: ["Nagpur", "Hyderabad"] },
{ city: "Rewa", connectedTo: ["Delhi", "Indore", "Raipur"] }
],
result: ""
};
},
created() {
const destination = this.$route.params.city.toLowerCase();
for (let i = 0; i < this.routes.length; i++) {
const connections = this.routes[i].connectedTo;
for (let j = 0; j < connections.length; j++) {
if (connections[j].toLowerCase() === destination) {
this.result = this.routes[i].city;
break;
}
}
if (this.result) {
break;
}
}
}
};
```
```
http://localhost:8080
```
```
http://localhost:8080/#/raipur
```
app.js
```javascript
const router = new VueRouter({
routes: [
{
path: "/:city",
component: Flights
}
]
});
new Vue({
el: "#app",
router
});
```
Which of the following best explains the conceptual difference between the broker and the backend?```python
celery_app = Celery(
'tasks',
broker='redis://localhost:6379/1',
backend='redis://localhost:6379/2',
include=['tasks']
)
```
The
getter is used in a Vue component as shown below:
Now suppose the Vuex getter
is removed, while the temperature state continues to be updated through Vuex mutations. Which of the following implementations correctly recreates
in the component so that it automatically reacts whenever the Vuex
changes?```javascript
const store = new Vuex.Store({
state: {
temperature: 30
},
getters: {
weatherStatus(state) {
return state.temperature >= 35 ? "Hot" : "Normal"
}
}
})
```
weatherStatus
```javascript
computed: {
weatherStatus() {
return this.$store.getters.weatherStatus
}
}
```
weatherStatus
weatherStatus
temperature
```javascript
computed: {
weatherStatus() {
return this.$store.state.temperature >= 35
? "Hot"
: "Normal"
}
}
```
```javascript
watch: {
weatherStatus() {
return this.$store.state.temperature >= 35
? "Hot"
: "Normal"
}
}
```
```javascript
methods: {
weatherStatus() {
this.$store.state.temperature >= 35
? "Hot"
: "Normal"
}
}
```
```javascript
watch: {
weatherStatus() {
return this.$store.state.temperature >= 35
}
}
```
| Column I | Column II | | :------- | :-------- | | 1. Unit Testing | A. Testing application behaviour across different browsers | | 2. E2E Testing | B. Commonly used for writing and running tests | | 3. Cross-Browser Testing | C. Testing individual Vue components independently | | 4. Jest / Mocha / Chai | D. Testing a complete application flow including backend interaction |

| Column I | Column II | |---|---| | 1. First Contentful Paint (FCP) | A. Measures unexpected movement of page elements | | 2. Largest Contentful Paint (LCP) | B. Measures how long the page is blocked from responding to user interaction | | 3. Total Blocking Time (TBT) | C. Measures when something first appears on the screen | | 4. Cumulative Layout Shift (CLS) | D. Measures when the largest visible content is rendered |
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?```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
```
launches the app on
; the developer should have run npm start to compile for production instead.``` npm run build ``` ``` localhost:8080 ```
and
do the same thing — both launch the app at 
``` npm run build ``` ``` npm run serve ``` ``` localhost:8080 ```
is correct for local development;
is only used for deploying to a server.``` npm run build ``` ``` npm run serve ```
compiles and bundles the app for production into a
folder — it does not start a local server. The developer should have run
instead.``` npm run build ``` /dist ``` npm run serve ```
What will be output on the browser’s console?```javascript
function outerFunc() {
const val1 = 10;
var val2 = 20;
function innerFunc() {
var val2 = 30;
console.log(val1)
console.log(val2)
}
innerFunc()
console.log(val1)
console.log(val2)
}
outerFunc()
```
``` 10 20 10 30 ```

``` 10 20 10 20 ```

``` 10 30 10 20 ```

```javascript const numbers = [10, 20, 30, 40, 50]; const [num1, , num2, ...rest] = numbers; const [a = 100, b = 200] = [undefined, 0]; console.log(num1, num2, rest); console.log(a, b); ```

```javascript
const user = {
id: 1,
profile: {
name: "Riya",
address: {
city: "Pune",
zip: "411001"
}
}
};
const {
profile: {
name,
address: { city, state = "Maharashtra" }
},
role = "guest",
profile
} = user;
console.log(name, city, state, role);
console.log(profile);
```

Riya Pune Maharashtra guest
```
{ name: "Riya", address: { city: "Pune", zip: "411001" } }
```

Riya Pune Maharashtra guest undefined

```
undefined undefined Maharashtra guest
```
```json
{ "name": "Riya", "address": { ...} }
```
, because you cannot destructure profile into nested variables and also assign it to a plain variable profile in the same statement.SyntaxError
What is the order of console output?```javascript
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");
Promise.resolve().then(() => {
console.log("5");
setTimeout(() => console.log("6"), 0);
});
```
| Directive | Description | |---|---| | 1. v-if | A. Two-way binding between input and data | | 2. v-for | B. Conditionally renders DOM elements | | 3. v-bind | C. Binds HTML attributes dynamically | | 4. v-model | D. Renders a list of items |

```javascript
const calculator = {
value: 10,
add(a, b) {
return this.value + a + b;
}
};
const rawAdd = calculator.add;
const boundAdd = calculator.add.bind({ value: 100 }, 5);
console.log(rawAdd(1, 2));
console.log(boundAdd(10));
console.log(calculator.add.apply({ value: 50 }, [1, 2]));
```
evaluates to 
``` rawAdd(1, 2) ``` NaN
evaluates to 
``` boundAdd(10) ``` 115
evaluates to 
```
calculator.add.apply({ value: 50 }, [1, 2])
```
53
throws a 
```
calculator.add.apply({ value: 50 }, [1, 2])
```
TypeError
A client first accesses
and then tries to access
. Which of the following statements are correct?```python
from flask import Flask, jsonify
from flask_jwt_extended import JWTManager, create_access_token, \
jwt_required
app = Flask(__name__)
app.config["JWT_SECRET_KEY"] = "secret"
jwt = JWTManager(app)
@app.route("/token")
def token():
access_token = create_access_token(identity="Ravi")
return jsonify(access_token=access_token)
@app.route("/dashboard")
@jwt_required()
def dashboard():
return jsonify(message="Dashboard Access Granted")
```
/token
/dashboard
can only be accessed if a valid JWT token is sent with the request./dashboard
header while accessing protected routes.Authorization
is automatically stored by Flask and reused for future requests./token
about its output:

TRUE
```javascript
const value = "global";
const obj = {
value: "objectValue",
regularMethod: function () {
console.log(this.value);
},
arrowMethod: () => {
console.log(this.value);
},
nested: {
value: "nestedValue",
regularInNested: function () {
console.log(this.value);
},
arrowInNested: () => {
console.log(this.value);
},
},
delayedRegular: function () {
setTimeout(function () {
console.log(this.value);
}, 100);
},
delayedArrow: function () {
setTimeout(() => {
console.log(this.value);
}, 100);
},
};
```
```javascript
obj.regularMethod();
obj.arrowMethod();
obj.nested.regularInNested();
obj.nested.arrowInNested();
obj.delayedRegular();
obj.delayedArrow();
```
logs "objectValue"``` obj.regularMethod() ```
logs "objectValue"``` obj.arrowMethod() ```
logs "nestedValue"``` obj.nested.regularInNested() ```
logs 
``` obj.nested.arrowInNested() ``` undefined
logs "objectValue"``` obj.delayedArrow() ```
logs "objectValue"``` obj.delayedRegular() ```
Which of the following statements are correct? (Select all that apply)```python
app.config["JWT_SECRET_KEY"] = "my-secret"
jwt = JWTManager(app)
@jwt.user_identity_loader
def load(user):
return user.username
@jwt.user_lookup_loader
def user_lookup(_jwt_header, jwt_data):
identity = jwt_data["sub"]
return User.query.filter_by(username=identity).one_or_none()
@app.route('/login', methods=["POST"])
def login():
user = User.query.filter_by(username="u1").one_or_none()
token = create_access_token(identity=user)
return {"access_token": token}
@app.route('/dashboard')
@jwt_required()
def dashboard():
return {
"username": current_user.username
}
```
decorator ensures that only requests with a valid JWT can access
.``` @jwt_required() ``` /dashboard
determines what value is stored in the "sub" field of the JWT.``` user_identity_loader ```
is removed,
will not be automatically populated.``` user_lookup_loader ``` current_user
directly stores the entire user object inside the JWT.```python create_access_token(identity=user) ```
will still execute but
will be None./dashboard current_user
object is reconstructed using the identity extracted from the JWT.current_user
Note: Each sub question runs on its own, starting from the original 'user' object. Based on the above data, answer the given subquestions.
```javascript
const cloned = { ...user }
cloned.name = "Amit"
cloned.skills.push("JavaScript")
console.log(user.name)
console.log(user.skills.length)
```
```javascript
const cloned = {
...user,
skills: [...user.skills]
}
cloned.skills.push("JavaScript")
console.log(user.skills.length)
console.log(cloned.skills.length)
```
Based on the above data, answer the given subquestions.
pauses the execution of the
function until the Promise resolves.await ``` display() ```
immediately returns the resolved string "Data Received".``` fetchData() ```
functions cannot return a
.async Promise
would cause
to store a
object instead of the resolved value.await result Promise

is accessed three times in a row in the template without price or discount changing in between, how many times does
get logged?discountedPrice "computing..."
is changed twice in two separate updates (100 to 120, then 120 to 150 on a later tick), what is the value of
afterward?price ``` logCount ```
Called from a view/script:
Checked immediately, right after delay() — worker hasn't processed it yet:
Called separately, after waiting for the worker to finish the task:


10 **and** <class 'int'>

A task ID string and <class 'celery.result.AsyncResult'>

None and <class 'NoneType'>

10 and <class 'celery.result.AsyncResult'>
component's method:

navigate the browser to?``` goToProduct() ```
navigate the browser to?``` goToSearch() ```
component, what expression correctly reads the
value from the URL after navigation?SearchResults keyword