Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Multiple choice questions on Javascript

Answer»

Below are the most common JavaScript questions that are asked frequently
(1)Is the following a valid variable definition? var 100apples
No
Yes
Answer:-No

(2)You want to create an alert. Select the correct one
alert('goodbye");
alert('he said "goodbye" ');
alert("goodbye');
Answer:-alert('he said "goodbye" ');

(3)JavaScript has to called inside ________ tags
Either in body or head
head
body
script
Answer:-script

(4)Is the following a valid variable assignment var product cost = 3.45;
No. There should be no space in the variable name
No. Floating numbers are not allowed
Yes. It is valid
Answer:-No. There should be no space in the variable name

(5)What option would you specify when inserting code in a web page? script type="____"
text/language
JavaScript/text
text/JavaScript
Answer:-text/JavaScript

(6)What is the ideal place to load the external JavaScript file in your HTML document
Towards the beginning of the body to load the page along with the JavaScript code
Towards the end of the body to increase the performance of the webpage
Anywhere within the body is good enough
Answer:-Towards the end of the body to increase the performance of the webpage

(7)What is true about variables
7Wonders is a valid variable name to give
% is a valid first character for variable name
Variables are case sensitive
^US is a valid variable name
Answer:-Variables are case sensitive

(8)Select the statement that has correct JavaScript syntax
document.write("text")
alert stop ;
console.log("text");
Answer:-console.log("text");

(9)To display WHETHER a value is a number or not, ____ is used
isNan
NaN
undefined
isundefined
Answer:-isNan

(10)isNan function returns ______ if the argument is not a number otherwise it is ______
False/True
False/False
True / False
True / True
Answer:-True / False

(11)Multiple variables can be created and initialized in a single JavaScript statement
False
True
Answer:-True

(12)Which of the following are not valid in JavaScript?
"My name is "Harry" "
"My name is Harry"
My name is Harry'
"My name is 'Harry' "
Answer:-"My name is "Harry" "

(13)Code A: var x = 10; y = --x + 1;
alert(y);
Code B: var x = 10;
y = x-- + 1;
alert(y);
What is the output for code A and B?
10,11
10,10
11,10
11,11
Answer:-10,11

(14)Which statement will return the value false?
var result = 20 < 50;
var result = 30 >= 30;
var result = (20 === "20") && (50 < 30);
Answer:-var result = (20 === "20") && (50 < 30);

(15)What is the value of C? var a = 100; var b = "10"; var c = a + b;
10010
110
None
10100
Answer:-10010

(16)___________ is a pretest loop that will execute until the value of z equals 10
while (z >10) { z--; }
do { ++z; } while (z < 10);
for (var z= 1; z < 10; z++) { alert (z); }
Answer:-while (z >10) { z--; }

(17)____ allows you to loop through a block of code as long as the specified condition is true.
Tag
While
For
Answer:-While

(18)____ is used to exit a loop early.
Break
Alert
Exit
Continue
Answer:-Break

(19)Can arrays in JavaScript be extended?
Yes, they can be
No, they cannot be
May be, they can be extended conditionally
Answer:-Yes, they can be

(20)In multidimensional array mySubject, which of the following will allow assigning the value 100 in position 5 of the third

mySubject array?
mySubject[3][4] = 100
mySubject[5][3] = 100
mySubject[4][2] = 100
mySubject[2][4] = 100
mySubject[3][5] = 100
Answer:-mySubject[2][4] = 100

(21)Which is the correct way to create an array in JavaScript? I) var myProg = []; II) var myArray = ["C","Java","C++","Python"];

III) var myProg = new Array();
I, III
II, III
I, II
I, II & III
Answer:-I, II & III

(22)In JavaScript, object is a container of properties and functions. Properties are identified by ____ and behavior is identified by

_____
variables, functions
attributes, functions
attributes, variables
functions, variables
Answer:-variables, functions

(23)To retrieve the day of the month from the Date object, which is the code to select?
var date_obj = new Date(2016,1,1);
month_date = date_obj.toDateString();
month_day = date_obj.getDay();
month_date = date_obj.getMonth();
var month_day = date_obj.getDate();
Answer:-var month_day = date_obj.getDate();

(24)What is true about array
Can have combination of data types in a single array list
Must have same data types for array list
Answer:-Can have combination of data types in a single array list

(25)FIbonacci Series Program
function fibonacciSequence(input)
{
var a=0;b=1;c=0;
var array1=[0,1];
for(var i=2;i<=input;i++)
{
c=a+b;
a=b;
b=c;
array1.push(c)
}
return array1;
}
Above code is true ---
Above code is incorrect
Answer:-True

(26) What is true about functions : I) Functions are objects II) Can be assigned to a variable III) Can be anonymous IV) Return value

type has to be defined in function declaration
I, II
I, II, III
I, II, III, IV
I, II, IV
Answer:-I, II, III

(27)What is the output you get for the following code?
(function()
{
return typeof arguments; })
();
undefined
array
arguments
object
Answer:-object

(28)Object's properties are similar to variables and methods are similar to
Conditionals
Properties
Functions
Operators
Answer:-Functions

(29)What is the output for the following
function test(x) {
while(x < 5)
{ x++; }
return x; }
alert(test(2));
6
3
2
5
Answer:-5

(30)_____ is an function contained within an object
Object
None of the options
Function
Method
Answer:-Method

(31)Which of the following regarding scope is true?
Variables that have a local scope are only visible in the function in which they are declared
Function parameters are visible in the function in which they are used
Data that is stored in a variable when a function is called is never cleared out
All variables you use in your program have to be declared as global variables
Answer:-Variables that have a local scope are only visible in the function in which they are declared

(32)Function in JavaScript is an object. True or False ?
False
True
Answer:-True

(33)Anonymous functions can be created in JavaScript. What do anonymous function do?
Overwrite variables that are to be kept updated
Process a variable before passing it on to another function
Automatically define the scope of a value inside a parameter
Answer:-Process a variable before passing it on to another function

(34)What is the output of the following expression?
function multi(x,y) {
var c = x*y;
}
multi(20,3);
20
60
3
Nothing
Answer:-Nothing

(35)var i = 1; if (function f(){}) { i += typeof f; } x;
1
undefined
Nan
Error
Answer:-undefined

(36)What is the output for the following code
(function f(){
function f(){
return 1; }
return f();
function f()
{ return 2; } })();
NaN
1
2
Error
Answer:-2

(37)function multi(a,b) { var ans = a * b; return ans; } var c = _________
multi(15,2);
multi 15, 2;
multi();
Answer:-multi(15,2);

(38)What is the output you get for the following code?
(function()
{
return typeof arguments; })
();
arguments
array
object
undefined
Answer:-object

(39)Which statement about the name and id attributes of form fields is false?
It is customary to give form fields both attributes, with the same value if possible.
The id attribute is what is sent when the form is submitted.
The name attribute can be used to access the field using getElementsByName().
Either attribute may be omitted if it is unused.
Answer:-The id attribute is what is sent when the form is submitted.

(40)Document object is part of ____ object
System
Tree
WINDOW
Answer:-Window

(41)Using HTML button tag, JavaScript command can be executed by using ____ function
"alert('Button1');
"alert(Button1);"
"alert('Button1');"
"alert('Button");"
Answer:-"alert('Button1');

(42)By MODIFYING the DOM, the contents on the page also gets modified
True
False
Answer:-True

(43)For any structured document, _____ defines a standard set of objects
XML DOM
HTML DOM
Core DOM
Answer:-Core DOM

(44)Which statement accesses HTML classes?
getElementsByClassName
class.name
getElementById
Answer:-getElementsByClassName

(45)How many 'onload' events can be written in a page
2
1
None
Many
Answer:-1

(46)Which is the most preferred way of handling events?
Referencing an element with the event and assign a function as a value
Register a listener to an element
Writing the JavaScript as an attribute to an element
Answer:-Register a listener to an element

(47)AJAX requests can support data transfer in ______ format
None of the options
JSON
XML
Any
Answer:-Any

(48)_____ object is used to make calls and request data from server
GET
XML
XMLHttpRequest
Answer:-XMLHttpRequest

(48)The data from the AJAX request is usually in XML. True or False?
False
True
Answer:-False

2.

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

Answer»

What will HAPPEN if the BODY of a for/in loop DELETES a property that has not YET been enumerated?
Choose the correct option from below list
(1)The property will be stored in a cache
(2)The loop will not run
(3)That property will not be enumerated
(4)The property will be enumerated

Answer:-(3)That property will not be enumerated

3.

JavaScript Code can be called by using ____________

Answer»

JavaScript Code can be CALLED by using ____________
Choose the correct option from below list
(1)RMI
(2)Triggering EVENT
(3)Preprocessor
(4)Function/Method

Answer:-(4)Function/Method

4.

What is the return type of the remote server?

Answer»

What is the return type of the remote server?
CHOOSE the correct option from below LIST
(1)HTTP RESPONSE
(2)HTTP Request
(3)Get Request
(4)Post request

Answer:-(1)HTTP Response

5.

What do you mean by Coercion in Javascript?

Answer»

What do you MEAN by Coercion in Javascript?
Type coercion is ONE of the process in Javascript to CONVERT VALUE from one type to another. Just like string to NUMBER or object to boolean and many more.

6.

What will be the step of the interpreter in a jump statement when an exception is thrown?

Answer»

What will be the step of the interpreter in a jump statement when an EXCEPTION is THROWN?
CHOOSE the correct option from below list
(1)The interpreter STOPS its work
(2)The interpreter throws another exception
(3)The interpreter jumps to the nearest enclosing exception handler
(4)The interpreter throws an error

Answer:-(3)The interpreter jumps to the nearest enclosing exception handler

7.

What is Object Equality in Javascript?

Answer»

What is Object Equality in Javascript?
In javascript there are TWO purpose of Object Equality in Javascript.
(1)In first we used "==" to compare two variables with USING its data type. Just like below will return true if we compare:-
"2"==2
Here we will not CHECK its type but only the values.
(2)In second we used "===" to compare both DATATYPE and values. Here below will return FALSE:-
"2"==2
Here above will return false as one is string type and other is int type.

8.

What are the three important manipulations done in a for loop on a loop variable?

Answer»

What are the three important manipulations done in a for LOOP on a loop VARIABLE?
Choose the CORRECT OPTION from below list
(1)Updation, Incrementation, Initialization
(2)Initialization,TESTING, Updation
(3)Testing, Updation, Testing
(4)Initialization,Testing, Incrementation

Answer:-(2)Initialization,Testing, Updation

9.

What is closure in JavaScript?

Answer»

What is CLOSURE in JAVASCRIPT?
When we need to ACCESSED the variable which is defined outside the current SCOPE. We create a CLOSURES to accessed the variable which is defined outside the current scope and it is accessed from some inner scope.

10.

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

Answer»

One of the SPECIAL feature of an interpreter in reference with the for loop is that
Choose the correct option from below list
(1)Before each ITERATION, the interpreter EVALUATES the variable expression and assigns the NAME of the property
(2)The iterations can be infinite when an interpreter is used
(3)The body of the loop is executed only once
(4)All of the mentioned

Answer:-(1)Before each iteration, the interpreter evaluates the variable expression and assigns the name of the property

11.

Which of the following API can be used to get the timing without affecting the page loading process?

Answer»

Which of the following API can be used to GET the TIMING without affecting the PAGE loading process?
Choose the correct option from below list
(1)Navigation API
(2)Timing API
(3)Navigation Timing API
(4)Navigate API

Answer:-(1)Navigation API

12.

The basic purpose of the toLocaleString() is to _________

Answer»

The basic PURPOSE of the toLocaleString() is to _________
Choose the CORRECT option from below list
(1)return a localised object representation
(2)return a parsed string
(3)return a local time in the string FORMAT
(4)return a LOCALIZED string representation of the object

Answer:-(4)return a localized string representation of the object

13.

Which of the following are client-side JavaScript object?

Answer»

Which of the following are client-side JavaScript object?
Choose the correct option from below list
(1)DATABASE
(2)Cursor
(3)Client
(4)FILEUPLOAD

Answer:-(4)FileUpLoad

14.

Which property reports rotation around three different mouse wheel axes?

Answer»

Which property reports ROTATION AROUND three different mouse WHEEL axes?
Choose the correct option from below list
(1)ctrlKey
(2)alterX
(3)alterY
(4)DELTAX

Answer:-(4)deltaX

15.

Which best explains getSelection()?

Answer»

Which BEST explains getSelection()?
CHOOSE the correct option from below list
(1)Returns the VALUE of a selected OPTION
(2)Returns document.URL of the WINDOW in focus
(3)Returns the value of cursor-selected TEXT
(4)Returns the VALUE of a checked radio input

Answer:-(3)Returns the value of cursor-selected text

16.

Why shouldn t JavaScript functions not be too long?

Answer»

Why shouldn t JavaScript functions not be too long?
Choose the CORRECT option from below list
(1)USER FRIENDLINESS
(2)Tie up EVENT loops
(3)Browser becomes unresponsive
(4)All of the mentioned

Answer:-(4)All of the mentioned

17.

How can you send data using a Worker object?

Answer»

How can you send data using a WORKER object?
Choose the correct option from below list
(1)postMessage()
(2)SENDMESSAGE()
(3)Message()
(4)post()

Answer:(1)postMessage()

18.

Which object is passed as the argument to handlers for keydown, keyup, and keypress events?

Answer»

Which OBJECT is passed as the argument to handlers for KEYDOWN, keyup, and keypress events?
Choose the correct option from below list
(1)KeyboardEvent
(2)Key EVENT
(3)MOUSE Event
(4)Alphabet Event

Answer:-(1)KeyboardEvent

19.

Which of the following method will wait for certain milliseconds to execute a specified method?

Answer»

Which of the FOLLOWING METHOD will wait for certain milliseconds to EXECUTE a specified method?
Choose the CORRECT option from below list
(1)setInterval()
(2)setTimeout()
(3)setmilli()
(4)setseconds()

Answer: (1)setInterval()

20.

A function definition expression can be called

Answer»

A FUNCTION DEFINITION expression can be called
Choose the correct option from below list
(1)Function prototype
(2)Function literal
(3)Function definition
(4)Function declaration

Answer:-(2)Function literal

21.

How to remove item from dropdownlist in Javascript

Answer» FUNCTION removeitemfromdropdownlist()
{
VAR LEN = document.getElementById('dropdownlistid').options.length;
for(i=len-1; i>=1; i--)
{
document.getElementById('dropdownlistid').options.remove(i);
}
}
22.

A linkage of series of prototype objects is called as

Answer»

A LINKAGE of series of prototype OBJECTS is called as
Choose the CORRECT option from below list
(1)prototype stack
(2)prototype chain
(3)prototype CLASS
(4)prototypes

Answer:-(2)prototype chain

23.

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

Answer»

What kind of expression is new Point(2,3) ?
Choose the correct option from below list
(1)Primary Expression
(2)OBJECT Creation Expression
(3)INVOCATION Expression
(4)CONSTRUCTOR Calling Expression

Answer:-(2)Object Creation Expression

24.

Which two events will have the generated text for key events?

Answer»

Which two events will have the generated text for key events?
Choose the CORRECT OPTION from below list
(1)key and char
(2)char and text
(3)text and key
(4)key and value

Answer:-(1)key and char

25.

Different Data Types in Javascript in 2015?

Answer»

Different Data Types in JAVASCRIPT in 2015?
Below are the six different data types in Javascript
(1)NUMERIC
(2)String
(3)Boolean
(4)NULL
(5)undefined
(6)Symbol

26.

The JavaScript s syntax calling ( or executing ) a function or method is called

Answer»

The JavaScript s SYNTAX calling ( or executing ) a function or method is called
Choose the correct option from below list
(1)Primary EXPRESSION
(2)FUNCTIONAL expression
(3)INVOCATION expression
(4)Property Access Expression

Answer:-(3)Invocation expression

27.

Which property holds a DataTransfer object that contains information about the data being transferred and the formats in which it is available?

Answer»

Which property HOLDS a DataTransfer object that contains information about the data being TRANSFERRED and the FORMATS in which it is available?
Choose the correct option from below list
(1)dataTransfer
(2)transferData
(3)dataExchange
(4)exchangeData

Answer:-(1)dataTransfer

28.

Which of the following is one of the fundamental features of JavaScript?

Answer»

Which of the following is one of the fundamental FEATURES of JavaScript?
CHOOSE the CORRECT option from below list
(1)Single-threaded
(2)Multi-threaded
(3)Both Single-threaded and Multi-threaded
(4)Simple-threaded

Answer:-(1)Single-threaded

29.

Code to find how many days left in upcoming chirstmas day in Javascript?

Answer» CODE to FIND how MANY days left in UPCOMING chirstmas day in Javascript?
Below is the code to find the day REMAINING in upcoming chirstmas

Download Code


date difference
30.

regular expression for credit card like VISA, MASTER, AMEX

Answer»

This is a regular expression that validates all CREDIT card numbers including VISA, MASTER, AMEX

^((4 d{3})|(5[1-5] d{2})|(6011)|(34 d{1})|(37 d{1}))-? d{4}-? d{4}-? d{4}|3[4,7][ d s-]{15

31.

syntax to get dropdownlist text in javascript

Answer»

document.getElementById(ControlID).OPTIONS[document.
getElementById(ControlID).selectedIndex].TEXT

32.

How can we read and write a file by using JavaScript?

Answer»

How can we read and WRITE a file by using JavaScript?
There are 2 ways to read and write a file using Javascript
(1)First is by using ActiveX objects and code is given below
var fsoobject = new ActiveXObject("Scripting.FileSystemObject");
var sobject = fso.OpenTextFile("C: testexample.txt", 1, true);


(2)By using JavaScript extensions
fh = fopen(getScriptPath(), 0); to OPEN a file

33.

Use of Shift and Unshift keyword in Javascript?

Answer»

Use of SHIFT and Unshift keyword in JAVASCRIPT?
Below is the code to use Shift and Unshift keyword in any ARRAY then PRINT the shifting of array. Below is the code to use shift and Unshift in Javascript.

Code Shift Unshift

Output of Above Code is GIVEN below:-


Code Shift Unshift



Download Code

34.

Write name of top 10 array methods in JavaScript?

Answer» WRITE NAME of top 10 ARRAY methods in JavaScript?
If you are a programmer you knows array are important in every programming languages. And if you understand all of below array methods in JavaScript you will be pro in JavaScript programming.
(1)forEach
(2)map
(3)reduce
(4)filter
(5)find
(6)findIndex
(7)some
(8)Every
(9)sort
(10)splice
In above list 9 methods are iterative functions which means these are simply looping. And above methods are also higher order function which means function which TAKES other functions as parameters.
35.

Write down difference between JavaScript and (Java,C,Ruby,PHP,cSharp and Python)?

Answer»

Write down difference between JavaScript and (Java,C,Ruby,PHP,cSharp and Python)?
Below are the most available difference between JavaScript and Java,C,Ruby,PHP,C# and Python:-
(A)JavaScript vs Java
(1)JavaScript is dynamically and Java is statically types.
(2)JavaScript is not strongly typed but Java is strongly typed.
(3)Java have features that it is programming explicit control over threading like C#. And JavaScript hides much of this with its call-and-response function structure.
(4)In some of Java version like Java 8 have mechanism to embed JavaScript in Java so it can leverage several JavaScript benefits.
(5)In past JavaScript was only interpreted at one time but now it often run through a JIT compiler. On the other hand Java is compiled to bytecode first which is called intermediate form to run by JIT compiler.
(6)Java is mainly DESIGNED to support many large application with its robust namespace. But JavaScript doesn't offer it directly so developer have SYNTHESIZED it.
(7)Java once ran in browsers and servers but is largely limited to servers today. JavaScript once ran only in browsers but is now increasingly used on the server side too.
(8)Both Java and JavaScript supports many of languages. Here Cross-compilers will convert many languages to run on Java s JVM or JavaScript engines.

(B)JavaScript vs C
(1)C is statically and JavaScript is dynamically typed.
(2)C languages have power to work directly on computer's memory with the help of pointers and JavaScript doesn't have this feature.
(3)In C programming language developer need to manually allocate and deallocate blocks of memory. On the other hand JavaScript will do this automatically.
(4)C program is compiled in advance. On the other hand JavaScript is interpreted and sometime compiled at runtime with the help of JIT compiler(Just in time).
(5)It is necessary to recompile C code when its is moved to different processor and JavaScript doesn't need this.
(6)In C language it offers explicit control of threads but on there hand JavaScript helps users to juggle multiple jobs by splitting tasks into asynchronous functions that is mainly called when data is ready.
(7)C is used MOSTLY where we need very high performance just like it is used for embedded computers and applications just like operating systems. And on other hand JavaScript was first used only in web pages but now it is in new role in server application which is developed through Node.js.

(C)JavaScript vs Ruby
(1)Both of these languages are dynamically typed.
(2)Ruby uses the keyword "end and JavaScript uses curly brackets to define blocks while coding.
(3)In start JavaScript was once limited to run on client browser and on another hand Ruby ran on server with Rails framework.
(4)JavaScript takes many of ideas of Ruby while running in Nodes.js on Server. Ruby use Rails frameworks.
(5)JavaScript takes most of its syntax from Java and C. And Ruby takes most if its features from Perl and Smalltalk.
(6)JavaScript is so popular these days it is general-purpose language. And on another hand Ruby is generally limited to server application by using its Rails frameworks. And we can also use Ruby for their server-supporting command-line applications.

(D)JavaScript vs PHP
(1)JavaScript and PHP both are dynamically typed variables.
(2)JavaScript and PHP both are scripting languages which were originally interpreted at runtime. But now these are often transformed by JIT compiler.
(3)In the starting PHP was mainly designed for servers to assemble different HTML files and JavaScript ran inside the browser on the client. But now JavaScript is also building HTML files on the server too.
(4)PHP is rarely used for anything but assembling HTML. JavaScript is the foundation for increasingly complex interfaces in the browser and server-side stacks integrating business logic and databases.
(5)PHP is a relatively simple language focused on retrieving information from databases and formatting it as HTML. JavaScript is becoming a more general language used for both browser interaction and more general computation.

(E)JavaScript vs C#
(1)C# is statically and JavaScript is dynamically typed.
(2)C# is strongly typed but JavaScript is not.
(3)C# is compiled to bytecode first and then which is an intermediate form to run by JIT compiler. JavaScript in past was only interpreted but now it is often run through a JIT compiler.
(4)C# has feature that it support both operator and conversion overloading. But JavaScript doesn't have this.
(5)C# have another feature like it gives programming explicit control over threading same as Java do. JavaScript hides much of this with its call-and-response function structure.
(6)C# has one of powerful .NET component that is LINQ which adds native data querying capabilities. On the other hand JavaScript has a separate libraries which can cover different functionality one of them is Underscore.js.

(F)JavaScript vs Python
(1)Python was mainly design to run from the command line to support servers. JavaScript was mainly designed to support HTML pages in the browser.
(2)Python use indentation and whitespace while doing code and JavaScript will uses curly brackets to designate blocks of code.
(3)Both of these languages are popular in larger communities now.
(4)JavaScript is FOUND now on servers and on some other locations. Python is mainly used as data processing language in social science.
(5)Python has feature to use flexible parameter blocks for methods. But on another hand JavaScript always insists all parameters must be specified.
(6)Python responds to function calls only. But JavaScript code is mainly often driven by events such as mouse click or any keystrokes.
(7)JavaScript library mainly designed to do changes in HTML in the browser. There are many of Python libraries which are forced on data processing and analysis.

36.

The snippet that has to be used to check if a is not equal to null is _________

Answer»

The snippet that has to be used to check if a is not equal to null is _________
Choose the CORRECT OPTION from below list
(1)if(a!=null)
(2)if (!a)
(3)if(a!null)
(4)if(a!==null)

Answer:-(4)if(a!==null)

37.

Where cookies stored on the hard disk by default

Answer»

Cookies storage is depends upon the USERS browser and OPERATING System. When we USE Netscape with Windows Operating system all the cookies are stored in a single file called cookies.txt and location of cookies is as given Below:-
c: Program Files Netscape Users username cookies.txt

When we use IE each COOKIE is stored in a separate file named as usernamewebsite.txt.
c: Windows Cookies usernameWebsite.txt