Home
Current Affairs January 2024

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

Correct Answer :

D. 0


Explanation: For checking more than one condition the if else if loop is used. It is the extension of if else loop which is also sometimes known as if else ladder.

Related Questions

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

Among the keywords below, which one is not a statement?

A. debugger

B. with

C. if

D. use strict

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

Consider the following code snippet.
for(var p in o)
console.log(o[p]);

The above code is equivalent to which code?

A.

for (var i = 0;i < a.length;i++)
console.log(a[i]);

B.

for (int i = 0;i < a.length;i++)
console.log(a[i]);

C.

for (var i = 0;i <= a.length;i++)
console.log(a[i]);

D.

for (var i = 1;i < a.length;i++)
console.log(a[i]);

What is the correct answer?

4

What will be the output of the following Javascript code?
var a=3.7;
var b=2;
a=ciel(a)
document.writeIn(a*b);

A. 6

B. 7.4

C. 7.5

D. 8

What is the correct answer?

4

What will be the output of the following JavaScript code?
function printprops(o)
{
for(var p in o)
console.log(p + : + o[p] +
);
}

A. Prints the contents of each property of o

B. Returns undefined

C. Prints only one property

D. Prints the address of elements

What is the correct answer?

4

The reduce and reduceRight methods follow a common operation called __________

A. filter and fold

B. inject and fold

C. finger and fold

D. fold

What is the correct answer?

4

What will be the output of the following JavaScript code?
const obj1 = { property1: '10'};
const obj2 = Object.freeze(obj1);
obj2.property1 = '20';
console.log(obj2.property1);

A. 10

B. 20

C. Runtime error

D. Compilation error

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

What kind of expression is new Point(2,3)?

A. Primary Expression

B. Object Creation Expression

C. Invocation Expression

D. Constructor Calling Expression

What is the correct answer?

4

What will be the output of the following JavaScript code?

A. 1.01

B. 1.047

C. 1.00

D. 1.4

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 function definitions in JavaScript begins with _____________

A. Identifier and Parentheses

B. Return type and Identifier

C. Return type, Function keyword, Identifier and Parentheses

D. Identifier and Return type

What is the correct answer?

4

Which attribute is used to specify that the script is executed when the page has finished parsing? (only for external scripts)

A. parse

B. a sync

C. defer

D. type

What is the correct answer?

4

What will be the output of the following JavaScript code?
const object1 = {
property1: 20
};
console.log(Object.is(object1));

A. 20

B. true

C. false

D. error

What is the correct answer?

4

Among the keywords below, which one is not a statement?

A. debugger

B. with

C. if

D. use strict

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

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

When an empty statement is encountered, a JavaScript interpreter __________

A. Ignores the statement

B. Prompts to complete the statement

C. Throws an error

D. Shows a warning

What is the correct answer?

4

What will be the output of the following JavaScript code?
var arr=[1,2,3];
var rev=arr.reverse();
document.writeln(rev);

A. 1, 2, 3

B. 3, 2, 1

C. 3

D. 1

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 pop() method of the array does which of the following task?

A. decrements the total length by 1

B. increments the total length by 1

C. prints the first element but no effect on the length

D. updates the element

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

What is the correct answer?

4

A JavaScript program developed on a Unix Machine ________

A. will throw errors and exceptions

B. must be restricted to a Unix Machine only

C. will work perfectly well on a Windows Machine

D. will be displayed as a JavaScript text on the browser

What is the correct answer?

4

The one-liner code that concatenates all strings passed into a function is

A.

function concatenate()
{
return String.prototype.concat('', arguments);
}

B.

function concatenate()
{
return String.prototype.apply('', arguments);
}

C.

function concatenate()
{
return String.concat.apply('', arguments);
}

D.

function concatenate()
{
return String.prototype.concat.apply('', arguments);
}

What is the correct answer?

4

What will be the output of the following JavaScript code?
var grade='A';
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. 27

C. 8

D. 0

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

Consider the following JavaScript statements.
var text = testing: 1, 2, 3; // Sample text
var pattern = /d+/g // Matches all instances of one or more digits

In order to check if the pattern matches with the string text, the statement is ____________

A. text==pattern

B. text.equals(pattern)

C. text.test(pattern)

D. pattern.test(text)

What is the correct answer?

4

The property of a primary expression is ____________

A. stand-alone expressions

B. basic expressions containing all necessary functions

C. contains variable references alone

D. contains only keywords