0% found this document useful (0 votes)
12 views

Java Script MCQ Set Paper 3

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Java Script MCQ Set Paper 3

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

[Type]0

[Marks]1
[Negative Marks]0

Q.1) What is JavaScript?


[a] A programming language for creating web pages *
[b] A database management system
[c] A graphic design software
[d] A network protocol

Q.2) Which keyword is used to declare a variable in JavaScript?


[a] Var*
[b] int
[c] string
[d] variable

Q.3) What is the correct syntax for a JavaScript function?


[a] function myFunction() { } *
[b] myFunction = function() { }
[c] function = myFunction() { }
[d] myFunction()

Q.4) How do you write a comment in JavaScript?


[a] // This is a comment *
[b] <!-- This is a comment -->
[c] /* This is a comment */
[d] ' This is a comment '

Q.5) How do you check the data type of a variable in JavaScript?


[a] typeof *
[b] datatype
[c] vartype
[d] type

Q.6) What is the correct way to add an element to the end of an


array in JavaScript?
[a] array.push(element) *
[b] array.append(element)
[c] array.add(element)
[d] array.insert(element)

Q.7) How do you select an HTML element using its ID in JavaScript?


[a] document.getElementById('elementId') *
[b] document.getElementByClass('elementId')
[c] document.getElementByName('elementId')
[d] document.querySelector('#elementId')

Q.8) How do you create a JavaScript object?


[a] var obj = {} *
[b] var obj = new Object()
[c] var obj = Object.create()
[d] var obj = createObject()
Q.9) Which operator is used to compare both value and type in
JavaScript?
[a] === *
[b] ==
[c] !==
[d] =

Q.10) How do you convert a string to a number in JavaScript?


[a] parseInt() *
[b] parseFloat()
[c] toNumber()
[d] convertNumber()

Q.11) What is the result of the following expression: 3 + "2"?


[a] "32" *
[b] 5
[c] 32
[d] NaN

Q.12) What is the purpose of the "strict mode" in JavaScript?


[a] To enable modern JavaScript features
[b] To enforce stricter syntax rules and prevent common
mistakes *
[c] To optimize JavaScript code execution
[d] To provide additional security measures

Q.13) What does the "typeof" operator return for an array?


[a] "object" *
[b] "array"
[c] "list"
[d] "undefined"

Q.14) How do you create a new instance of an object in JavaScript?


[a] Using the "new" keyword *
[b] By assigning a value to a variable
[c] By declaring a function
[d] By calling the object's constructor directly

Q.15) What is the scope of a variable declared with the "let"


keyword?
[a] Global scope
[b] Function scope
[c] Block scope *
[d] Object scope

Q.16) What is the correct way to write a conditional statement in


JavaScript?
[a] if (condition) { // code block } *
[b] condition { // code block }
[c] (condition) => { // code block }
[d] if condition: // code block
Q.17) How do you access the length of an array in JavaScript?
[a] array.length *
[b] array.size
[c] array.length()
[d] array.count

Q.18) What is the difference between the "==" and "===" operators
in JavaScript?
[a] Both operators are identical
[b] "==" compares only the values, while "===" compares both
the values and types *
[c] "==" compares only the types, while "===" compares both
the values and types
[d] "==" is used for arithmetic operations, while "===" is
used for logical operations

Q.19) What is the purpose of the "this" keyword in JavaScript?


[a] It refers to the current function being executed
[b] It refers to the global object (window in a browser) *
[c] It refers to the previous element in an array
[d] It refers to the parent object of the current object

Q.20) How do you stop the execution of a JavaScript loop?


[a] Using the "break" statement *
[b] Using the "continue" statement
[c] Using the "return" statement
[d] By setting the loop condition to false

Q.21) What is the output of the following code snippet?

console.log(2 + "2" - 1);

[a] "21"
[b] 21
[c] 22
[d] 23*

Q.22) Which of the following is not a valid JavaScript data type?


[a] boolean
[b] string
[c] float
[d] char *

Q.23) What is the purpose of the "typeof" operator in JavaScript?


[a] To check if a variable is defined or not
[b] To determine the data type of a value *
[c] To convert a value to a specific data type
[d] To compare two values for equality

Q.24) Which of the following is a correct way to define a


JavaScript function?
[a] function myFunction() { } *
[b] def myFunction() { }
[c] myFunction = function() { }
[d] myFunction()
Q.25) How do you access the value of a property in a JavaScript
object?
[a] object.property *
[b] object.property()
[c] object.getProperty()
[d] object["property"]

Q.26) What is the output of the following code snippet?

console.log(typeof null);

[a] "null"
[b] "object" *
[c] "undefined"
[d] "boolean"

Q.27) Which keyword is used to declare a constant in JavaScript?


[a] const *
[b] var
[c] let
[d] final

Q.28) What is the result of the following expression: 4 * "5"?


[a] 9
[b] 20
[c] 45
[d] 4 * 5 *

Q.29) What does the "NaN" stand for in JavaScript?


[a] Not a Number *
[b] No Available Number
[c] Null and None
[d] Negative and Non-numeric

Q.30) How do you convert a string to uppercase in JavaScript?


[a] str.toUpperCase() *
[b] str.toUpper()
[c] str.upperCase()
[d] str.toUpperString()

You might also like