Quiz Space

January 2022 term · Modern Application Development II · BSCS2006

MAD 2 End Term: 3 April 2022 (January 2022 term)

The IIT Madras BS Modern Application Development II (MAD 2) End Term paper sat on 3 Apr 2022, in the January 2022 term: 32 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
32
Marks
100
Duration
180 min
MCQ
21
MSQ
11

Updated

Official paper: IIT M FOUNDATION DIPLOMA ENDTERM FN1 3 Apr 2022 · No negative marking.

Question 1

+2 marksOne correct option

Suppose you want to store some data on the client side that is used by the server to authenticate the user, and the data should survive a reboot of the client. Which of the following would you prefer the most to store the data to provide a good user experience?

  1. A

    Local Storage

  2. B

    Session based cookies

  3. C

    Session Storage

  4. D

    All of them

Show answer

Correct answer

  • A

    Local Storage

Question 2

+2 marksOne correct option

Which of the following statements is true regarding webhooks and web sockets?

  1. A

    A flask application cannot act as a webhook provider.

  2. B

    Webhooks are expected to have a detailed response body.

  3. C

    The communication that happens using web sockets is never concurrent.

  4. D

    Web sockets provide full-duplex communication.

Show answer

Correct answer

  • D

    Web sockets provide full-duplex communication.

Question 3

+2 marksOne correct option

Which of the following statements is false regarding fetch API?

  1. A

    The value of header “Content-Type” and the body content type should be the same for making a network call.

  2. B

    Files can be transmitted over the network using fetch calls.

  3. C

    The fetch call cannot be used for making an HTTP “PUT” request.

  4. D

    The promise returned by the fetch call does not reject for a 404 response.

Show answer

Correct answer

  • C

    The fetch call cannot be used for making an HTTP “PUT” request.

Question 4

+2 marksOne correct option

State whether the statement “Multi-threaded programs are only useful if you have multicore processors” is true or false?

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 5

+2 marksOne or more correct options

Which of the following statement(s) is/are true regarding JavaScript language?

Select all that apply.

  1. A

    JavaScript is a dynamically typed language.

  2. B

    Hoisting moves all the variable declarations, declared using “var” keyword, to the top of their scope.

  3. C

    Arrow functions cannot take parameters or arguments.

  4. D

    All of these

Show answer

Correct answers

  • A

    JavaScript is a dynamically typed language.

  • B

    Hoisting moves all the variable declarations, declared using “var” keyword, to the top of their scope.

Question 6

+2 marksOne or more correct options

Which of the following statement(s) is/are false regarding caching?

Select all that apply.

  1. A

    It is recommended to cache the social networking apps feed responses for a longer duration.

  2. B

    Caching is primarily done to reduce the load from the origin server.

  3. C

    The shared cache is meant to serve responses to the multiple users.

  4. D

    A browser cannot cache JavaScript corresponding to a web page.

Show answer

Correct answers

  • A

    It is recommended to cache the social networking apps feed responses for a longer duration.

  • D

    A browser cannot cache JavaScript corresponding to a web page.

Question 7

+2 marksOne or more correct options

Which of the following is/are true about server-sent-event?

Select all that apply.

  1. A

    Only the server can push data to the client.

  2. B

    The client can also push the data to the server.

  3. C

    The mime-type of data sent from the server should be “application/json”.

  4. D

    The mime-type of data sent from the server should be “text/event-stream”.

Show answer

Correct answers

  • A

    Only the server can push data to the client.

  • D

    The mime-type of data sent from the server should be “text/event-stream”.

Question 8

+2 marksOne or more correct options

Which of the following statement(s) is/are true, regarding celery?

Select all that apply.

  1. A

    Celery is a Python based package for dealing with asynchronous tasks.

  2. B

    Celery is generally used as a data store for cached results.

  3. C

    Celery can have multiple workers to execute tasks asynchronously.

  4. D

    None of these

Show answer

Correct answers

  • A

    Celery is a Python based package for dealing with asynchronous tasks.

  • C

    Celery can have multiple workers to execute tasks asynchronously.

Question 9

+3 marksOne correct option

Which of the following statements is false regarding the state of an application?

  1. A

    The system state is usually independent of the user interface.

  2. B

    The application state is seen by an end user of the application.

  3. C

    The ephemeral state typically lasts for a long period of time.

  4. D

    The entire database of LinkedIn is an example of system state.

Show answer

Correct answer

  • C

    The ephemeral state typically lasts for a long period of time.

Question 10

+3 marksOne correct option

Consider the following Vue application with markup index.html, and javascript file app.js.

index.html:

html
<div id = "demo">
<input v-model = "name" v-on:input = "check" />
<p :class = "[isError ? 'btn btn-danger' : 'btn btn-success']"> Correct?
</p>
</div>
<script src = "app.js">

app.js:

javascript
const app = new Vue({
el: '#demo',
data: {
name : "",
isError : true,
},
mounted () {
if (localStorage.name) {
this.name = localStorage.name;
this.isError = localStorage.isError;
}
},
methods: {
check: function () {
if (this.name.length > 3)
this.isError = false;
else
this.isError = true;
localStorage.name = this.name;
localStorage.isError = this.isError;
}
}
})

Say you open the “index.html” file in a browser, and write “abhi” in the text input shown on screen, then force reload the page (without clicking anywhere). What will be the value in the input text box and class applied to the paragraph element with text “Correct?”, respectively?

  1. A

    ‘abhi’, ‘btn btn-success’

  2. B

    Empty, ‘btn btn-success’

  3. C

    ‘abhi’, ‘btn btn-danger’

  4. D

    Empty, ‘btn btn-danger’

Show answer

Correct answer

  • C

    ‘abhi’, ‘btn btn-danger’

Question 11

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">From Index.html</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const vm = new Vue({
el: '#app',
template: '<div>From Vue instance</div>',
})

Suppose the application is running on “http://localhost:8080” what will be rendered on the screen by the browser for the URL, “http://localhost:8080”?

  1. A

    From Index.html

  2. B

    From Vue instance

  3. C

    From Index.html
    From Vue instance

  4. D

    From Vue instance
    From Index.html

Show answer

Correct answer

  • B

    From Vue instance

Question 12

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const vm = new Vue({
el: '#app',
template: '<div>From Vue instance</div>',
data: {
instiName: 'IIT Madras',
},
beforeCreate() {
console.log(this.instiName ? 'Apple' : 'Mango')
},
created() {
console.log(this.instiName ? 'Apple' : 'Mango')
},
})

Suppose the application is running on “http://localhost:8080”. What will be logged on the console, when the user loads the application for the first time?

  1. A

    Mango
    Apple

  2. B

    Apple
    Mango

  3. C

    Apple
    Apple

  4. D

    Mango
    Mango

Show answer

Correct answer

  • A

    Mango
    Apple

Question 13

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<score></score>
<div style="margin-top: 10px">
<add-four></add-four>
<add-six></add-six>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/vuex@2.0.0"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const Score = {
template: `<div>{{ this.$store.state.profile.name }}: {{runs}}</div>`,
computed: {
runs() {
return this.$store.state.profile.runs
},
},
}
const addFour = {
template: `<button @click="addFourRun"> Add Four </button>`,
methods: {
addFourRun() {
store.commit('increaseRun', 7)
},
},
}
const addSix = {
template: `<button @click="addSixRun"> Add Six </button>`,
methods: {
addSixRun() {
store.commit('increaseRun', 5)
},
},
}
const store = new Vuex.Store({
state: {
profile: { name: 'Narendra', runs: 35 },
},
mutations: {
increaseRun(state, run) {
state.profile.runs += run
},
},
})
const app = new Vue({
el: '#app',
store,
components: {
score: Score,
'add-four': addFour,
'add-six': addSix,
},
})

Suppose the application is running on “localhost:8080”. What will be rendered by the browser in the <score> component, if the user loads the application for the first time?

  1. A

    Narendra: 0

  2. B

    Narendra: 35

  3. C

    Narendra: 54

  4. D

    Narendra: 49

Show answer

Correct answer

  • B

    Narendra: 35

Question 14

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file index.html.

index.html:

html
<body>
<div id="app">
<div v-for="item in items">
<b>{{item.item_name}}: {{item.count}}</b>
<button-comp :item_name="item.item_name" count="5"></button-comp>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const buttonComp = {
template: `<button @click="addItem()"> Add {{item_name}}</button>`,
props: ['item_name', 'count'],
methods: {
addItem() {
const item = this.$parent.items.filter(
(item) => item.item_name != this.item_name
)
item[0].count += Number(this.count)
},
},
}
const vm = new Vue({
el: '#app',
data: {
items: [
{
count: 10,
item_name: 'Item1',
},
{
count: 0,
item_name: 'Item2',
},
],
},
components: {
'button-comp': buttonComp,
},
})

Suppose the application is running on “localhost:8080”. What will be rendered by the browser, if the user loads the application for the first time (excluding the buttons)?

  1. A

    Item1: 10
    Item2: 0

  2. B

    Item1: 0
    Item2:10

  3. C

    Item1: 0
    Item2: 0

  4. D

    Item1: 10
    Item2: 10

Show answer

Correct answer

  • A

    Item1: 10
    Item2: 0

Question 15

+3 marksOne correct option

Which of the following statements is true?

  1. A

    Session cookies are automatically sent by the client to the server on each request.

  2. B

    Permanent cookies are sent to the server only on the first request of a session.

  3. C

    All items in local storage are automatically sent by the client to the server on the first request.

  4. D

    None of these

Show answer

Correct answer

  • A

    Session cookies are automatically sent by the client to the server on each request.

Question 16

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<router-view></router-view>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const Mobile = {
template: `<div><h1>Mobile: {{this.$route.params.model}}</h1>
<h2>Price: {{this.$route.params.price}} Rs.</h2></div>
`,
}
const DefautMobile = {
template: `<div><h1>Mobile: Nokia 1500</h1>
<h2>Price: 1500 Rs.</h2></div>`,
}
const error = {
template: `<div> No mobile to show </div>`,
}
const MobileStore = {
template: `<div><h1>Welcome to Mobile Store</h1>
<div><router-view></router-view></div></div>`,
}
const routes = [
{
path: '/',
component: MobileStore,
children: [
{ path: '', component: error },
{
path: 'mobile/:model/:price',
component: Mobile,
},
{ path: '*', component: DefautMobile },
],
},
]
const router = new VueRouter({ routes, base: '/' })
const vm = new Vue({ el: '#app', router })

Suppose the application is running on “http://localhost:8080”. What will be rendered inside the router-view (index.html) for the URL, “http://localhost:8080/#/”?

  1. A

    Welcome to Mobile Store
    Mobile: Nokia 1500
    Price: 1500 Rs.

  2. B

    Welcome to Mobile Store
    No mobile to show

  3. C

    Welcome to Mobile Store
    Mobile: Samsung
    Price: 1800 Rs.

  4. D

    No mobile to show

Show answer

Correct answer

  • B

    Welcome to Mobile Store
    No mobile to show

Question 17

+3 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<router-view></router-view>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const Mobile = {
template: `<div><h1>Mobile: {{this.$route.params.model}}</h1>
<h2>Price: {{this.$route.params.price}} Rs.</h2></div>
`,
}
const DefautMobile = {
template: `<div><h1>Mobile: Nokia 1500</h1>
<h2>Price: 1500 Rs.</h2></div>`,
}
const error = {
template: `<div> No mobile to show </div>`,
}
const MobileStore = {
template: `<div><h1>Welcome to Mobile Store</h1>
<div><router-view></router-view></div></div>`,
}
const routes = [
{
path: '/',
component: MobileStore,
children: [
{ path: '', component: error },
{
path: 'mobile/:model/:price',
component: Mobile,
},
{ path: '*', component: DefautMobile },
],
},
]
const router = new VueRouter({ routes, base: '/' })
const vm = new Vue({ el: '#app', router })

Suppose the application is running on “http://localhost:8080”. What will be rendered inside the router-view (index.html) for the URL, “http://localhost:8080/#/laptop”?

  1. A

    Welcome to Mobile Store
    Mobile: Nokia 1500
    Price: 1500 Rs.

  2. B

    Welcome to Mobile Store
    No mobile to show

  3. C

    Welcome to Mobile Store
    Mobile: Samsung
    Price: 1800 Rs.

  4. D

    No mobile to show

Show answer

Correct answer

  • A

    Welcome to Mobile Store
    Mobile: Nokia 1500
    Price: 1500 Rs.

Question 18

+3 marksOne correct option

Which of the following statements is true regarding SQLite database?

  1. A

    SQLite is best suited for handling multiple concurrent write operations.

  2. B

    SQLite is best suited for handling multiple concurrent read operations.

  3. C

    SQLite databases do not follow ACID constraints.

  4. D

    An SQLite database will always occupy more RAM than a MySQL database for the same data.

Show answer

Correct answer

  • B

    SQLite is best suited for handling multiple concurrent read operations.

Question 19

+3 marksOne or more correct options

Which of the following statement(s) is/are false regarding the following 2 code snippets?

Code snippet 1:

javascript
let x = [1, 2, 3]
x.length = 5
for (i in x){
console.log(x[i])
}

Code snippet 2:

javascript
let x = [1, 2, 3]
x.length = 5
for (i of x){
console.log(i)
}

Select all that apply.

  1. A

    Both the code snippets will give the same output.

  2. B

    Code snippet 1 will result in an error.

  3. C

    Code snippet 2 will result in an error.

  4. D

    The length of the array “x” will be 5, after executing code snippet 2.

Show answer

Correct answers

  • A

    Both the code snippets will give the same output.

  • B

    Code snippet 1 will result in an error.

  • C

    Code snippet 2 will result in an error.

Question 20

+3 marksOne or more correct options

Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    It is safe to say that all single page applications are also progressive web applications.

  2. B

    A frontend server is generally optimized to serve only the static assets, and the other requests are redirected to the application server.

  3. C

    The presence of web workers need not be required at the client for server sent events.

  4. D

    The processing speed of a machine is hardware dependent.

Show answer

Correct answers

  • B

    A frontend server is generally optimized to serve only the static assets, and the other requests are redirected to the application server.

  • D

    The processing speed of a machine is hardware dependent.

Question 21

+3 marksOne or more correct options

Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    A message broker can reduce the number of connections each individual server needs to accept in a multiserver system.

  2. B

    A message broker helps in easier scalability in a distributed architecture.

  3. C

    The messages in the message queue are lost/destroyed, if no receiver is available.

  4. D

    The point-to-point messaging always requires the use of a message broker as intermediary.

Show answer

Correct answers

  • A

    A message broker can reduce the number of connections each individual server needs to accept in a multiserver system.

  • B

    A message broker helps in easier scalability in a distributed architecture.

Question 22

+3 marksOne or more correct options

Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    The performance of static sites is generally better than the dynamic websites.

  2. B

    The caching can be used at multiple levels in a network architecture to improve the performance.

  3. C

    Data in local storage is automatically synchronized between mobile and desktop devices used by the same user.

  4. D

    All of these

Show answer

Correct answers

  • A

    The performance of static sites is generally better than the dynamic websites.

  • B

    The caching can be used at multiple levels in a network architecture to improve the performance.

Question 23

+3 marksOne or more correct options

Which of the following statement(s) is/are true regarding pub/sub messaging?

Select all that apply.

  1. A

    Communication between publisher and subscriber is generally asynchronous.

  2. B

    Subscriber uses polling to pull data from the message broker.

  3. C

    Data is automatically pushed to the subscribers as soon as the producer pushes the data to the message queue.

  4. D

    All of these

Show answer

Correct answers

  • A

    Communication between publisher and subscriber is generally asynchronous.

  • C

    Data is automatically pushed to the subscribers as soon as the producer pushes the data to the message queue.

Question 24

+3 marksOne or more correct options

You are trying to build a distributed system with N servers, each of which may need to communicate with any of the other servers. Which of the following statement(s) is/are true?

Select all that apply.

  1. A

    With point-to-point communication, the number of connection links will grow as O(n).

  2. B

    With point-to-point communication, the number of connection links will grow as O(n²).

  3. C

    With the use of a central message broker, the number of connection links will grow as O(n).

  4. D

    With the use of a central message broker, the number of connection links will grow as O(n²).

Show answer

Correct answers

  • B

    With point-to-point communication, the number of connection links will grow as O(n²).

  • C

    With the use of a central message broker, the number of connection links will grow as O(n).

Question 25

+4.5 marksOne correct option

Consider the following JavaScript program, and predict the output if executed.

javascript
var first = 1
obj1 = {
'first' : 2,
'second' : function some () {
console.log(this.first)
}
}
obj2 = {
'first' : 3,
'second' : function some () {
this.second()
}
}
obj2.second.call(obj1)
  1. A

    1

  2. B

    2

  3. C

    3

  4. D

    None of these

Show answer

Correct answer

  • B

    2

Question 26

+4.5 marksOne correct option

Consider the following JavaScript program, and predict the output if executed.

  1. A

    9

  2. B

    8

  3. C

    7

  4. D

    Error

Show answer

Correct answer

  • B

    8

Question 27

+4.5 marksOne correct option

Consider the following JavaScript program, and predict the output if executed.

javascript
new Promise((res, rej) => {
if (9 === "9") rej(10)
else res(20)
})
.then(d => {
console.log("hello 1", d);
throw new Error(20);
return d * 10;
})
.then(d => {
console.log("hello 2", d);
return d;
})
.catch(e => {
console.log("hello 3");
return e * 10;
})
.finally(d => {
console.log("hello 4", d);
return d * 10;
})
.then(d => {
console.log("hello 5", d);
return d * 10;
})
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 28

+4.5 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<score></score>
<div style="margin-top: 10px">
<add-four></add-four>
<add-six></add-six>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/vuex@2.0.0"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const Score = {
template: `<div>{{ this.$store.state.profile.name }}: {{runs}}</div>`,
computed: {
runs() {
return this.$store.state.profile.runs
},
},
}
const addFour = {
template: `<button @click="addFourRun"> Add Four </button>`,
methods: {
addFourRun() {
store.commit('increaseRun', 7)
},
},
}
const addSix = {
template: `<button @click="addSixRun"> Add Six </button>`,
methods: {
addSixRun() {
store.commit('increaseRun', 5)
},
},
}
const store = new Vuex.Store({
state: {
profile: { name: 'Narendra', runs: 35 },
},
mutations: {
increaseRun(state, run) {
state.profile.runs += run
},
},
})
const app = new Vue({
el: '#app',
store,
components: {
score: Score,
'add-four': addFour,
'add-six': addSix,
},
})

Suppose the application is running on “localhost:8080”, what will be rendered by the browser in the <score> component, if the user loads the application for the first time and clicks on the button “Add Four” two times and “Add Six” one time?

  1. A

    Narendra: 0

  2. B

    Narendra: 35

  3. C

    Narendra: 54

  4. D

    Narendra: 49

Show answer

Correct answer

  • C

    Narendra: 54

Question 29

+4.5 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<player>
<template></template>
<template v-slot:test><p>This is for test</p></template>
<template v-slot:oneday><p>{{oneday}}</p></template>
</player>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const player = {
template: `
<div>
<slot> Not Available </slot>
<slot name="test"> Not Available </slot>
<slot name="oneday"> Not Available </slot>
</div>
`,
}
const app = new Vue({
el: '#app',
data: {
test: 'This is test data',
oneday: 'This is oneday data',
profile: 'This is players profile',
},
components: {
player: player,
},
})

Suppose the application is running on “localhost:8080”. What will be rendered by the browser when the user visits the URL, “localhost:8080” for the first time?

  1. A

    Not Available
    Not Available
    Not Available

  2. B

    This is test data
    This is oneday data
    This is players profile

  3. C

    Not Available
    This is oneday data
    This is players profile

  4. D

    Not Available
    This is for test
    This is oneday data

Show answer

Correct answer

  • D

    Not Available
    This is for test
    This is oneday data

Question 30

+4.5 marksOne correct option

Consider the below Vue application with markup index.html and javascript file index.html.

index.html:

html
<body>
<div id="app">
<div v-for="item in items">
<b>{{item.item_name}}: {{item.count}}</b>
<button-comp :item_name="item.item_name" count="5"></button-comp>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const buttonComp = {
template: `<button @click="addItem()"> Add {{item_name}}</button>`,
props: ['item_name', 'count'],
methods: {
addItem() {
const item = this.$parent.items.filter(
(item) => item.item_name != this.item_name
)
item[0].count += Number(this.count)
},
},
}
const vm = new Vue({
el: '#app',
data: {
items: [
{
count: 10,
item_name: 'Item1',
},
{
count: 0,
item_name: 'Item2',
},
],
},
components: {
'button-comp': buttonComp,
},
})

Suppose the application is running on “localhost:8080”, and after loading the application for the first time, if user clicks on the button “Add Item1” for 3 times and “Add Item2” for 4 times, then what will be rendered by the browser (excluding the buttons)?

  1. A

    Item1: 30
    Item2: 15

  2. B

    Item1: 15
    Item2: 30

  3. C

    Item1: 25
    Item2: 20

  4. D

    Item1: 20
    Item2: 25

Show answer

Correct answer

  • A

    Item1: 30
    Item2: 15

Question 31

+4.5 marksOne correct option

Consider the below Vue application with markup index.html and javascript file app.js.

index.html:

html
<body>
<div id="app">
<router-view></router-view>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script
src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
<script src="app.js"></script>
</body>

app.js:

javascript
const Mobile = {
template: `<div><h1>Mobile: {{this.$route.params.model}}</h1>
<h2>Price: {{this.$route.params.price}} Rs.</h2></div>
`,
}
const DefautMobile = {
template: `<div><h1>Mobile: Nokia 1500</h1>
<h2>Price: 1500 Rs.</h2></div>`,
}
const error = {
template: `<div> No mobile to show </div>`,
}
const MobileStore = {
template: `<div><h1>Welcome to Mobile Store</h1>
<div><router-view></router-view></div></div>`,
}
const routes = [
{
path: '/',
component: MobileStore,
children: [
{ path: '', component: error },
{
path: 'mobile/:model/:price',
component: Mobile,
},
{ path: '*', component: DefautMobile },
],
},
]
const router = new VueRouter({ routes, base: '/' })
const vm = new Vue({ el: '#app', router })

Suppose the application is running on “http://localhost:8080”. What will be rendered inside the router-view (index.html) for the URL, “http://localhost:8080/#/mobile/Samsung/1800”?

  1. A

    Welcome to Mobile Store
    Mobile: Nokia 1500
    Price: 1500 Rs.

  2. B

    Welcome to Mobile Store
    No mobile to show

  3. C

    Welcome to Mobile Store
    Mobile: Samsung
    Price: 1800 Rs.

  4. D

    No mobile to show

Show answer

Correct answer

  • C

    Welcome to Mobile Store
    Mobile: Samsung
    Price: 1800 Rs.

Question 32

+4.5 marksOne or more correct options

Consider the given 2 implementations.

Approach 1:

driver code:

python
import tasks
def generate_reports():
users = User.query.all()
for user in users:
tasks.job_report.delay(user)

celery job:

python
@celery.task
def job_report(user):
'''
This function fetches the statistics of a given user and generates an
HTML report
'''

Approach 2:

driver code:

python
import tasks
def generate_reports():
tasks.job_report.delay()

celery job:

python
@celery.task
def job_report():
users = User.query.all()
for user in users:
'''
This loop fetches the statistics of a given user and generates an HTML
report
'''

Suppose there are currently 1000 users in the database, and the application is supposed to generate 1000 HTML reports. Which of the following statement(s) is/are true (assuming there are more than 1 workers)?

Select all that apply.

  1. A

    Approach 1 will finish the task in less time than approach 2.

  2. B

    Approach 2 will finish the task in less time than approach 1.

  3. C

    Both the approaches will be comparable.

  4. D

    Both the approaches will be comparable if there is only 1 worker available.

  5. E

    None of these

Show answer

Correct answers

  • A

    Approach 1 will finish the task in less time than approach 2.

  • D

    Both the approaches will be comparable if there is only 1 worker available.