Hi Guest

HomePage

1 1

To improves our performance please Like Share Subscribe(Will boost us)

Multiple choice questions on Javascript
Question Posted on 29 Dec 2018

Home >> JavaScript >> JavaScript Questions >> Multiple choice questions on Javascript

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
0
0



Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions
regular expression for credit card like VISA, MASTER, AMEX
How to remove item from dropdownlist in Javascript
Different Data Types in Javascript in 2015?
syntax to get dropdownlist text in javascript
The snippet that has to be used to check if “a” is not equal to “null” is _________






Most Visited Questions
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |
     
 
Privacy policy | Terms and Conditions | Blog


If the copyright of any questions or content or syntax belong to you email us we will remove that(info@crackyourinterview.com or crackyourinterview2018@gmail.com)
 

1
Home About Us GroupChat
 
Sitemap Feedback Contact us