Home
Current Affairs January 2024

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10

B. 0

C. 18

D. 17

Correct Answer :

B. 0


Explanation: The switch case contains a default case along with the other cases. The default case gets executed when no other case results into true.

Related Questions

What is the correct answer?

4

A conditional expression is also called a _______________

A. Alternative to if-else

B. Immediate if

C. If-then-else statement

D. Switch statement

What is the correct answer?

4

One of the special feature of an interpreter in reference with the for loop is that ___________

A. Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property

B. The iterations can be infinite when an interpreter is used

C. The body of the loop is executed only once

D. the iteration is finite when an interpreter is used

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10

B. 0

C. 18

D. 17

What is the correct answer?

4

What will be the output of the following JavaScript code?
Int a=1;
if(a>10)
{
document.write(10);
}
else
{
document.write(a);
}

A. 10

B. 0

C. 1

D. Undefined

What is the correct answer?

4

The main purpose of a Live Wire in NetScape is to ________

A. Create linkage between client side and server side

B. Permit server side, JavaScript code, to connect to RDBMS

C. Support only non relational database

D. To interpret JavaScript code

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='E';
var result;
switch(grade)
{
case 'A':
result+=10;
case 'B':
result+= 9;
case 'C':
result+= 8;
default:
result+= 0;
}
document.write(result);

A. 10

B. 0

C. 18

D. 17

What is the correct answer?

4

Consider the following code snippet.
while (a != 0)
{
if (a == 1)
continue;
else
a++;
}

What will be the role of the continue keyword in the above code snippet?

A. The continue keyword restarts the loop

B. The continue keyword skips the next iteration

C. The continue keyword skips the rest of the statements in that iteration

D. The continue keyword breaks out of the loop

What is the correct answer?

4

The escape sequence stands for _________

A. Floating numbers

B. Representation of functions that returns a value

C. is not present in JavaScript

D. Form feed

What is the correct answer?

4

A function definition expression can be called as __________

A. Function prototype

B. Function literal

C. Function calling

D. Function declaration

What is the correct answer?

4

JavaScript Code can be called by using ____________

A. RMI

B. Triggering Event

C. Preprocessor

D. Function/Method

What is the correct answer?

4

A hexadecimal literal begins with __________

A. 00

B. 0x

C. 0X

D. Both 0x and 0X

What is the correct answer?

4

What will be the output of the following JavaScript code?
var a=5 , b=1
var obj = { a : 10 }
with(obj)
{
alert(b)
}

A. 10

B. Error

C. 1

D. 5

What is the correct answer?

4

If you have a function f and an object o, you can define a method named m of o with

A. o.m=m.f;

B. o.m=f;

C. o=f.m;

D. o=f;

What is the correct answer?

4

The generalised syntax for a real number representation is __________

A. [digits][.digits][(E|e)[(+|-)]digits]

B. [digits][+digits][(E|e)[(+|-)]digits]

C. [digits][(E|e)[(+|-)]digits]

D. [.digits][digits][(E|e)[(+|-)]digits]

What is the correct answer?

4

What will be the firstname and surname of the following JavaScript code?
var book = {
main title: JavaScript,
'sub-title': The Definitive Guide,
for: all audiences,
author: {
firstname: David,
surname: Flanagan
}
};

A. properties

B. property values

C. property names

D. objects

What is the correct answer?

4

Which keyword is used to define the function in javascript?

A. void

B. int

C. function

D. main

What is the correct answer?

4

What will be the output of the following Javascript code?
var txt1 = good;
var txt2 = day;
document.getElementById(demo).innerHTML = txt1 + txt2;

 

A. good day

B. goodday

C. error

D. undefined

What is the correct answer?

4

What will happen if the body of a for/in loop deletes a property that has not yet been enumerated?

A. The property will be stored in a cache

B. The loop will not run

C. That property will not be enumerated

D. The property will be enumerated

What is the correct answer?

4

The purpose of extensible attribute is to __________

A. make all of the own properties of that object non configurable

B. to configure and bring a writable property

C. lock down objects into a known state and prevent outside tampering

D. to include new properties into the object

What is the correct answer?

4

The enumeration order becomes implementation dependent and non-interoperable if ___________

A. If the object inherits enumerable properties

B. The object does not have the properties present in the integer array indices

C. The delete keyword is never used

D. Object.defineProperty() is not used

What is the correct answer?

4

What is the prototype represents in the following JavaScript code snippet?
function f() {};

A. Function f

B. A custom constructor

C. Prototype of a function

D. Not valid

What is the correct answer?

4

Do functions in JavaScript necessarily return a value?

A. It is mandatory

B. Not necessary

C. Few functions return values by default

D. some functions do not return any value

What is the correct answer?

4

Consider the following code snippet.
function printArray(a)
{
var len = a.length, i = 0;
if (len == 0)
console.log(Empty Array);
else
{
do
{
console.log(a[i]);
} while (++i < len);
}
}

What does the above code result?

A. Prints the numbers in the array in order

B. Prints the numbers in the array in the reverse order

C. Prints 0 to the length of the array

D. Prints Empty Array

What is the correct answer?

4

What will be the output of the following JavaScript code?
var obj=
{
length:20,
height:35,
}
if (breadth' in obj === false)
{
obj.breadth = 12;
}
console.log(obj.breadth);

A. 20

B. 12

C. undefined

D. error

What is the correct answer?

4

What will be the possible output of the following JavaScript code?
var a = [1,2,3,4,5];
a.slice(0,3);

A. Returns [1,2,3]

B. Returns [4,5]

C. Returns [1,2,3,4]

D. Returns [1,2,3,4,5]

What is the correct answer?

4

What will be the output of the following JavaScript code?
int a=4;
int b=1;
int c=0;
If(a==b)
document.write(a);
else if(a==c)
document.write(a);
else
document.write(c);

A. 4

B. 1

C. Error

D. 0

What is the correct answer?

4

What will be the output of the following JavaScript code?
var pow=new Function(num1,num2,return Math.pow(num1,num2));
document.writeln(pow(2,3));

A. 2

B. 3

C. 8

D. error

What is the correct answer?

4

What will the following code snippet work? If not, what will be the error?
function tail(o)
{
for (; o.next; o = o.next) ;
return o;
}

A. No, this will throw an exception as only numerics can be used in a for loop

B. No, this will not iterate

C. Yes, this will work

D. No, this will result in a runtime error with the message Cannot use Linked List

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='B';
var result;
switch(grade)
{
case 'A':
{
result+=10;
break;
}
case 'B':
{
result+= 9;
break;
}
case 'C':
{
result+= 8;
break;
}
default:
result+= 0;
}
document.write(result);

A. 10

B. 9

C. 8

D. 0

What is the correct answer?

4

Identify the process done in the following JavaScript code snippet?
o = {x:1, y:{z:[false,null,]}};
s = JSON.stringify(o);
p = JSON.parse(s);

A. Object Encapsulation

B. Object Serialization

C. Object Abstraction

D. Object Encoding