Home
Current Affairs January 2024

What is the correct answer?

4

The script tag must be placed in __________

A. the head tag

B. the head or body

C. the title or head

D. after the body tag

Correct Answer :

B. the head or body


Explanation: If the script tag is placed after the body tag, then, it will not be evaluated at all. Also, it is always recommended and effective to use the script snippet in the tag.

Related Questions

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

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

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

What will be the output of the following JavaScript code?
function equalto()
{
int num=10;
if(num===10)
return true;
else
return false;
}

A. true

B. false

C. runtime error

D. compilation error

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

In the following syntax, the data type within the square brackets must be ___________
book[datatype]=assignment_value;

A. An integer

B. A String

C. An object

D. Floating point

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

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

Consider the following code snippet :
var tensquared = (function(x) {return x*x;}(10));

Will the above code work ?

A. Yes, perfectly

B. Error

C. Exception will be thrown

D. Memory leak

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

Consider the following code snippet :
var grand_Total=eval(10*10+5);

The output for the above statement would be :

A. 10*10+5

B. 105 as a string

C. 105 as an integer value

D. Exception is thrown

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 will be the output of the following JavaScript code?
int sum=0;
var arr = [10,15,20,30];
arr.forEach(function myFunction(element)
{
sum= sum+element;
});
document.writeln(sum);

A. 70

B. 75

C. 10

D. error

What is the correct answer?

4

A proper scripting language is a __________

A. High level programming language

B. Assembly level programming language

C. Machine level programming language

D. Low level programming language

What is the correct answer?

4

The var and function are __________

A. Keywords

B. Declaration statements

C. Data types

D. Prototypes

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

What will be the output of the following JavaScript code?
string a = hi;
string b =there;
alert(a+b);

A. hi

B. there

C. hithere

D. undefined

What is the correct answer?

4

The type of a variable that is volatile is _______________

A. Volatile variable

B. Mutable variable

C. Immutable variable

D. Dynamic variable

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

What will happen if reverse() and join() methods are used simultaneously?

A. Reverses and stores in the same array

B. Reverses and concatenates the elements of the array

C. Reverses

D. Stores the elements of an array in normal order

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

What is the correct answer?

4

Consider the following code snippet :
function constfuncs()
{
var funcs = [];
for(var i = 0; i < 10; i++)
funcs[i] = function() { return i; };
return funcs;
}
var funcs = constfuncs();
funcs[5]()

What does the last statement return ?

A. 9

B. 0

C. 10

D. None of the mentioned

What is the correct answer?

4

What will be the output of the following JavaScript code?
function compare()
{
int a=1;
char b=1;
if(a.tostring()===b)
return true;
else
return false;
}

A. true

B. false

C. runtime error

D. logical error

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

What will be the shift() output of the following JavaScript code?
var a = [];
a.unshift(1);
a.unshift(22);
a.shift();
a.unshift(3,[4,5]);
a.shift();
a.shift();
a.shift();

A. 1

B. [4,5]

C. [3,4,5]

D. Exception is thrown

What is the correct answer?

4

What will be the output of the following JavaScript code?
var a1 = [,,,];
var a2 = new Array(3);
0 in a1
0 in a2

A. true false

B. false true

C. true true

D. false true

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

What is the purpose of a return statement in a function?

A. Returns the value and continues executing rest of the statements, if any

B. Returns the value and stops the program

C. Returns the value and stops executing the function

D. Stops executing the function and returns the value

What is the correct answer?

4

The web development environment (JavaScript) offers which standard construct for data validation of the input entered by the user.

A. Controlled loop constructs

B. Case checking constructs

C. Validation constructs

D. All of the mentioned

What is the correct answer?

4

For the below mentioned code snippet:
var o = new Object();

The equivalent statement is:

A. var o = Object();

B. var o;

C. var o= new Object;

D. Object o=new Object();