Home

SBI Clerk - JavaScript 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. Among the following, which one is a ternary operator?
A. +
B. :
C. ^
D. ?:
Answer : D
2. What will be the output of the following JavaScript code?
var values=[1,2,3,4]
var ans=values.slice(1);
document.writeln(ans);

A. 1, 2, 3, 4
B. 2, 3, 4
C. 1, 3, 4
D. error
Answer : D
3. A hexadecimal literal begins with __________
A. 00
B. 0x
C. 0X
D. Both 0x and 0X
Answer : D
4. Which is a more efficient JavaScript code snippet?
Code 1 :
for(var num=10;num>=1;num--)
{
document.writeln(num);
}

Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}

A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare
Answer : A
5. What will be the output of the following JavaScript code?
var person =
{
name: Rahul,
getName: function()
{
nreturn this.name;
}
}
var unboundName = person.getName;
var boundName = unboundName.bind(person);
document.writeln(boundName());

A. runtime error;
B. compilation error
C. Rahul
D. undefined
Answer : C
6. What will be the output of the following JavaScript code?
const object1 = {};
a = Symbol('a');
b = Symbol.for('b');
object1[a] = 'harry';
object1[b] = 'derry';
const objectSymbols = Object.getOwnPropertySymbols(object1);
console.log(objectSymbols.length);

A. 0
B. 2
C. 1
D. Error
Answer : B
7. 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
Answer : C
8. 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
Answer : A
9. 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
Answer : D
10. 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
Answer : C
11. What will be the output of the following JavaScript code?

A. 1.01
B. 1.047
C. 1.00
D. 1.4
Answer : B
12. What will be the output of the following JavaScript code?
function height()
{
var height = 123.56;
var type = (height>=190) ? tall : short;
return type;
}

A. 123.56
B. 190
C. tall
D. short
Answer : D
13. Consider the following code snippet
function f(o)
{
if (o === undefined) debugger;
}

What could be the task of the statement debugger?

A. It does nothing but a simple breakpoint
B. It debugs the error in that statement and restarts the statements execution
C. It is used as a keyword that debugs the entire program at once
D. It is used to find error in the statement
Answer : A
14. The var and function are __________
A. Keywords
B. Declaration statements
C. Data types
D. Prototypes
Answer : B
15. 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
Answer : B
16. What will be the output of the following Javascript code?
var a = 10;
do {
a += 1;
console.log(a);
} while (a < 5);

A. 11121314
B. 1112
C. 12345
D. 11
Answer : D
17. Which of the operator is used to test if a particular property exists or not?
A. in
B. exist
C. within
D. exiss
Answer : A
18. 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
Answer : C
19. The object has three object attributes namely ________
A. Class, parameters, objects extensible flag
B. Prototype, class, objects parameters
C. Prototype, class, objects extensible flag
D. Native object, Classes and Interfaces and Objects extensible flag
Answer : C
20. 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
Answer : C
21. JavaScript Code can be called by using ___________
A. RMI
B. Triggering Event
C. Preprocessor
D. Function/Method
Answer : D
22. 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
Answer : C
23. 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]
Answer : A
24. What happens in the following javaScript code snippet?
var count = 0;
while (count < 10)
{
console.log(count);
count++;
}

A. The values of count are logged or stored in a particular location or storage
B. The value of count from 0 to 9 is displayed in the console
C. An error is displayed
D. An exception is thrown
Answer : B
25. When does the function name become optional in JavaScript?
A. When the function is defined as a looping statement
B. When the function is defined as expressions
C. When the function is predefined
D. when the function is called
Answer : B
26. What will be the output of the following JavaScript code?

A. 7.25
B. -7.25
C. 7
D. -7
Answer : A
27. What will be the output of the following Javascript code?
int size=5;
int a=5;
int size=4;
for(int j=size;j>=0;j--)
{
console.log(a);
a=a-2;
}

A. 5555
B. 5321
C. 531-1
D. 531
Answer : C
28. What will be the output of the following JavaScript code?
int a==2;
int b=4;
int ans=a+b;
print(ans);

A. 2
B. 6
C. 0
D. error
Answer : D
29. 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
Answer : C
30. In the following switch syntax, the expression is compared with the case labels using which of the following operator(s)?
switch(expression)
{
statements
}

A. ==
B. equals
C. equal
D. ===
Answer : D
31. What will be the output of the following Javascript code?
int a=0;
for(a;a<5;a++);
console.log(a);

A. 0
B. error
C. 4
D. 5
Answer : D
32. What will be the output of the following JavaScript code?
function code(id,name)
{
this.id = id;
this.name = name;
}
function pcode(id,name)
{
code.call(this,id,name);
}
document.writeln(new pcode(101,vivek).id);

A. vivek
B. 101
C. Runtime error
D. Compilation error
Answer : B
33. Which is a more efficient JavaScript code snippet?
Code 1 :
for(var num=10;num>=1;num--)
{
document.writeln(num);
}

Code 2 :
var num=10;
while(num>=1)
{
document.writeln(num);
num++;
}

A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare
Answer : A
34. 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
Answer : B
35. What will be the output of the following Javascript code?
var arr = [7, 5, 9, 1];
var min = Math.min.apply(null, arr);
document.writeln(min);

A. 7
B. 5
C. 1
D. 9
Answer : C
36. Consider the following code snippet :
var c = counter(), d = counter();
c.count()
d.count()
c.reset()
c.count()
d.count()

The state stored in d is :

A. 1
B. 0
C. Null
D. Undefined
Answer : A
37. 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
Answer : C
38. Assume that we have to convert false that is a non-string to string. The command that we use is (without invoking the new operator).
A. false.toString()
B. String(false)
C. String newvariable=false
D. Both false.toString() and String(false)
Answer : D
39. 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
Answer : C
40. What will happen if a return statement does not have an associated expression?
A. It returns the value 0
B. It will throw an exception
C. It returns the undefined value
D. It will throw an error
Answer : C
41. What will be the output of the following JavaScript code?
var values=[one,two,Three];
var ans=values.shift();
document.writeln(ans);

A. one
B. two
C. three
D. error
Answer : A
42. 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
Answer : A
43. The basic purpose of the toLocaleString() is to _________
A. return a localised object representation
B. return a parsed string
C. return a local time in the string format
D. return a localized string representation of the object
Answer : D
44. 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
Answer : A
45. 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
Answer : B
46. 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
Answer : A
47. The type of a variable that is volatile is _______________
A. Volatile variable
B. Mutable variable
C. Immutable variable
D. Dynamic variable
Answer : B
48. What will be the output of the following JavaScript code?
var arr = [7, 5, 9, 1];
var value = Math.max.apply(null, arr);
document.writeln(value);

A. 7
B. 5
C. 1
D. 9
Answer : D
49. The var and function are __________
A. Keywords
B. Declaration statements
C. Data types
D. Prototypes
Answer : B
50. 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
Answer : A

Sharing is caring