JavaScript/JAVASCRIPT MCQ Sample Test,Sample questions

Question:
	
-Infinity in JS gets added with -Infinity then output of the code will be

1.+Infinity

2.NaN

3.-Infinity

4.None of the above


Question:
	
Comments in JS are ignored by ____________.

1.Compiler

2.Operating System

3. JVM

4.Browser


Question:
	
How can you get the type of arguments passed to a function?

1.using typeof operator

2.using getType function

3.Both of the above.

4.None of the above


Question:
	
JavaScript code contain sequence of ___________.

1.HTML Tags

2.Method Calls

3.Executable Statements

4.All of the these


Question:
	
JS Comment can be used for following purposes -

1.to Hide Non-usable line

2.to Hide Non-usable Multiline Code

3.used for Documentation

4.All of these


Question:
	
Person XYZ wrote his name and date of code creation at the start , What kind of comment he has written ?

1. Functional Comment

2.Code Hiding Comment

3. Documentation Comment

4.None of These


Question:
	
State the correct place of JS Code inside HTML -

1.Inside Body

2.Inside Head

3.Inside Single JavaScript File

4.All of these


Question:
	
Which of the following function of String object executes the search for a match between a regular expression and a specified string?

1.concat()

2.match()

3.replace()

4.search()


Question:
	
Which of the following is a valid type of function javascript supports?

1.named function

2.anonymous function

3.Both of the above

4.None of the above


Question:
	
Which of the following is not a compound assignment operator ?

1.===

2.<<=

3.+=

4.>>=


Question:
+Infinity in JS gets added with +Infinity then output of the code will be

1.NaN

2.+Infinity

3.-Infinity

4.Null


Question:
....................... is a built - in JavaScript function which can be used to execute another function after a given time interval.

1.Timeout( )

2.TimeInterval( )

3.setTimeout ( )

4.All of the above


Question:
43.	
Java Statement terminated by ______________ .

1.Slash

2.Semicolon

3.Full Stop

4.Comma


Question:
Below Code contain one executive Statement. Guess the Output of the Code.
<script type="text/javascript">
    {
        document.Write("<h1>This is a heading</h1>");
    }
</script>

1."This is a heading" will be printed in H1 heading

2.Just "This is a heading" will be printed because HTML tags are not allowed

3.Will not print anything

4.None of these


Question:
Comment Statement is _________________ type of statement.

1.Executive

2.Non Important

3.Non Executable

4. Non Usable


Question:
Cost for Using JavaScript in your HTML is _________ .

1.Its Free !!!

2. $10 / Year

3.$15 / Year

4. $5 / Year


Question:
During addition of two numbers , suppose one of the number is NaN then output of the following code will be ?

1.NaN

2.Zero

3.Infinite

4.Null


Question:
Executable single line of Script is called as _________________.

1.Statement in JavaScript

2.Breakpoint in JS

3.Line in JS

4.None of These


Question:
Group of JavaScript Statements is called as _________

1.Statement Block

2.Group

3.Cluster

4. Code Block


Question:
If a string cannot be converted to a number __________ will be returned.

1. NaN

2.Infinite

3.Null

4.Zero


Question:
If the values on either side of '+' operator are numerical values then ___________.

1.values are concatenated together

2.values are added together

3.no effect

4.None of These


Question:
In March 1996, _______________ was released, featuring support for JavaScript.

1.Netscape Navigator 1.0

2.Internet Explorer 2.0

3.Netscape Navigator 2.0

4.Internet Explorer 1.0


Question:
Integer Variable is declared using following syntax in JavaScript.

1. Integer num;

2.var num;

3. int num;

4.integer num;


Question:
Java Script entities start with ___________and end with _____________.

1. Semicolon, colon

2.Semicolon, Ampersand

3.Ampersand, colon

4.Ampersand, semicolon


Question:
JavaScript Code is written inside file having extension __________.

1..jvs

2..javascript

3. .js

4. .jsc


Question:
JavaScript is invented by ________.

1.Brendan Eich

2.Helsinki, Linus

3.W3 Group

4.James Gosling


Question:
JavaScript is ______ Side Scripting Language.

1. Server

2.ISP

3.Browser

4.None of the these


Question:
Javascript is _________ language.

1.Programming

2.Application

3.Scripting

4.None of These


Question:
JavaScript Statements are executed by ________ .

1.Server

2.JVM

3.Compiler

4.Browser


Question:
JavaScript was invented at _______ Lab .

1.Netscape

2.Google Lab

3.AT&T Bell Lab

4.Sun Microsystem


Question:
JavaScript was originally developed under the name _______.

1.ActionScript

2.Mocha

3.Oak

4.Sencha


Question:
Local Browser used for validations on the Web Pages uses __________.

1.Java

2.CSS

3.HTML

4.JS


Question:
Microsoft Developed a compatible dialect of JavaScript called _____________.

1.JScript

2.MS JavaScript

3.MJavaScript

4.Advanced JavaScript


Question:
Multiple Declarations of variables are separated by ___________ symbol.

1.Semicolon

2.Colon

3.Comma

4.Asterisk


Question:
Multiple JS statements are written inside pair of ________ to form a statement block.

1. Pair of Square Brackets

2.Pair of Round Brackets

3.Pair of Curly braces

4.None of these


Question:
Single Line Comment in JavaScript Starts with _________ Symbol.

1.""

2. "//"

3. "$$"

4."#"


Question:
Spaces,Punctuation marks are called as __________ Symbols in JavaScript.

1. Special

2.Punctual

3.Mandetory

4. None of these


Question:
The async attribute can be set in the following ways -

1.<script async>

2.<script async="">

3.<script async="async">

4.All of the these


Question:
var num;
Above Statement is called as __________ Statement.

1.Instantization

2.Globalization

3. Declaration

4.Initialization


Question:
var var1 = "Pritesh";
Above variable can store value of type -

1.Integer

2.String

3.Any Type

4.None of these


Question:
var var1 = "Pritesh";
Above variable can store value of type -

1.Integer

2.String

3.Any Type

4.None of These


Question:
Variable can hold ________ value at a time.

1. Multiple

2.Double

3.Single

4.None of These


Question:
Variable name contain following type of characters -

1. Alphabet
2. Digits
3. Underscore
4. Special Characters

Select the correct option.

1.3 4 2

2.4 3 1

3.1 2 3 4

4.1 2 3


Question:
We can declare all type of variables in JavaScript with the keyword __________

1.var

2.obj

3.jvar

4.None of these


Question:
We can declare all type of variables in JavaScript with the keyword _____________.

1. var

2.obj

3.jvar

4.None of These


Question:
We can declare ___________ at a time. Select most appropriate option.

1.One Variable Only

2.One or more Variables

3.More than One Variables

4.None of these


Question:
We use _______ style comment to prevent showing Java Script as Content in the old browsers.

1.JS

2.CSS

3.HTML

4.C


Question:
What will be printed ?
<html>
    
    <head>
        <title>A Simple Page</title>
        <script language="JavaScript">
            <!--
            var A = "Compile ",
                B = "Error";
            C = A + B;
            alert(C);
            //  -->
        </script>
    </head>
    
    <body></body>

</html>

1."Compile Error" will be printed

2."Compile" will be printed

3.Nothing will be printed

4.None of the above


Question:
What will be printed inside webpage ?
var message="Hello JS";
document.write(Message);

1.It will crash browser since No Error handler is provided

2.Hello JS

3."Hello JS" will be printed multiple times

4.Nothing Will be printed because Code is not error free


Question:
What will be the Output of the below Code ?
<html>
<body>
<script type="text/javascript">
<!--
document.print("Hello");
//-->
</script>
</body>
</html>

1.Will Throw Error

2.Hello

3.Will not print anything because of Comment

4.None of These


Question:
What will be the value of Variable 'output' ?
var str = "Str";
var num = 10;

var output = str + num;

1.Nothing will be printed

2.Str10

3.Null

4.NaN


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

1. type

2.defer

3.async

4. parse


Question:
Which built-in method returns the calling string value converted to upper case?

1. toUpperCase()

2.toUpperCase()

3.changeCase(case)

4.None of the above


Question:
Which JavaScript variable cannot be used as First character but can be use after first character ?

1.Asterisk

2.Dollar Sign

3.Underscore

4.Digit


Question:
Which of the following Attribute is used to include External JS code inside your HTML Document ?

1.link

2.script

3.ext

4.ext


Question:
Which of the following function of Array object removes the first element from an array and returns that element?

1.reverse()

2. shift()

3. slice()

4.some()


Question:
Which of the following function of Number object returns the number's value?

1. toString()

2.valueOf()

3.toLocaleString()

4.toPrecision()


Question:
Which of the following function of String object causes a string to be displayed as struck-out text, as if it were in a strike tag?

1.sup()

2.small

3.strike()

4. sub()


Question:
Which of the following function of String object creates an HTML anchor that is used as a hypertext target?

1.anchor()

2.link()

3.blink()

4.big()


Question:
Which of the following function of String object returns a number indicating the Unicode value of the character at the given index?

1. charAt()

2.charCodeAt()

3.concat()

4.indexOf()


Question:
Which of the following function of String object returns the calling string value converted to upper case while respecting the current locale?

1.toLocaleUpperCase()

2. toUpperCase()

3. toString()

4.substring()


Question:
Which of the following function of String object returns the index within the calling String object of the first occurrence of the specified value?

1.substr()

2.search()

3.lastIndexOf()

4.indexOf()


Question:
Which of the following is a server-side Java Script object?

1.Function

2.File

3.FileUpload

4.Date


Question:
Which of the following is considered as End of Single line comment ?

1.End of Line

2.Semicolon

3.End of Statement

4."*/" Symbol


Question:
Which of the following is correct about JavaScript?

1.JavaScript is a lightweight, interpreted programming language.

2.JavaScript has object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.

3.The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.

4.All of the above


Question:
Which of the following is the correct syntax to print a page using JavaScript?

1.window.print();

2.browser.print();

3.navigator.print();

4.document.print();


Question:
Which of the following is the correct syntax to redirect a url using JavaScript?

1.document.location='http://www.newlocation.com';

2.browser.location='http://www.newlocation.com';

3. navigator.location='http://www.newlocation.com';

4.window.location='http://www.newlocation.com';


Question:
Which of the following is true about variable naming conventions in JavaScript?

1.You should not use any of the JavaScript reserved keyword as variable name.

2.JavaScript variable names should not start with a numeral (0-9).

3.Both of the above.

4.None of These


Question:
Which of the following statement is used to declare variable in JavaScript ?

1.Assignment Statement

2.Conditional Statement

3.Executable Statement

4.Declaration Statement


Question:
Which of the following type of variable is visible only within a function where it is defined?

1. global variable

2. local variable

3. Both of the above.

4.None of the above


Question:
Which of the statement will be neglected by Browser ?

1.<p>Google</p>

2.<p>Yahoo</p>

3.<h1>Heading</h1>

4.All Statements


Question:
Which was the first browser to support JavaScript ?

1.Mozilla Firefox

2.Google Chrome

3.IE

4.Netscape


Question:
Why JavaScript is called as Lightweight Programming Language ?

1.because JS is available free of cost

2.because JS is client side scripting

3.because we can add programming functionality inside JS

4.because JS can provide programming functionality inside but up to certain extend


Question:
______ attribute is used to specify the character encoding used in an external script file.

1.type

2.charset

3.character

4.None of These


Question:
____________ is used to assign value to the variable.

1.Assignment Statement in JavaScript

2.Declaration Statement

3.Conditional Statement

4.Executable Statement


More MCQS

  1. JavaScript MCQ Questions And Answers
  2. JavaScript MCQ Questions And Answers Set 2
  3. JavaScript MCQ Set 1
  4. JavaScript MCQ Set 2
  5. Javascript MCQ Questions Set 1
  6. Javascript Multiple Choice Questions
  7. JAVASCRIPT MCQ
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!