0% found this document useful (0 votes)
5K views

Java Script MCQ Set Paper 5

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)
5K views

Java Script MCQ Set Paper 5

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/ 6

[Type]0

[Marks]1
[Negative Marks]0

Q.1) What is a string in JavaScript?


[a] A data type used to store multiple values.
[b] A function that performs a specific task.
*[c] A collection of characters enclosed in single or double quotes.
[d] A loop construct used for iteration.

[S1] This is for the solution

Q.2) How do you create a string in JavaScript?


*[a] Using single or double quotes around the text.
[b] Using the createString() function.
[c] Using the new String() syntax.
[d] Using the string() keyword.

[S1] This is for the solution

Q.3) How do you find the length of a string in JavaScript?


[a] Using the getSize() method.
[b] Using the count() function.
*[c] Using the length property.
[d] Using the count() function.

[S1] This is for the solution

Q.4) How do you access a specific character in a string?


[a] Using the getCharacter() function.
*[b] Using the charAt() method.
[c] Using the character index within square brackets.
[d] Using the access() keyword.

[S1] This is for the solution

Q.5) Which method is used to convert a string to uppercase in


JavaScript?
[a] upperCase()
[b] convertToUpper()
[c] toUpperCaseString()
*[d] toUpperCase()

[S1] This is for the solution


Q.6) How do you concatenate two or more strings in JavaScript?
[a] Using the join() function.
*[b] Using the concat() method.
[c] Using the merge() keyword.
[d] Using the add() method.

[S1] This is for the solution

Q.7) How do you find the index of a specific character or substring in a


string?
[a] Using the index() function.
[b] Using the findIndex() method.
[c] Using the search() method.
*[d] Using the indexOf() method.

Q.8) Which method is used to extract a portion of a string in


JavaScript?
[a] slice()
[b] extract()
*[c] substring()
[d] getSubstring()

[S1] This is for the solution

Q.9) How do you replace a substring within a string in JavaScript?

*[a] Using the replace() method.


[b] Using the swap() function.
[c] Using the replaceSubstring() keyword.
[d] Using the substitute() method.

[S1] This is for the solution

Q.10) How do you convert a string to an array of substrings in


JavaScript?
[a] Using the toArray() method.
*[b] Using the split() method.
[c] Using the convertToArray() function.
[d] Using the explode() keyword.

[S1] This is for the solution

Q.11) How many primitive data types are there in JavaScript?


[a]3
*[b]5
[c]4
[d]6
[S1] This is for the solution

Q.12) Which of the following is not a primitive data type in JavaScript?


[a] String
[b] Boolean
*[c] Object
[d] Number

[S1] This is for the solution

Q.13) Which data type is used to represent whole numbers in JavaScript?


[a] String
[b] Boolean
[c] Object
*[d] Number

[S1] This is for the solution

Q.14) Which data type is used to represent true/false values in


JavaScript?
[a] String
*[b] Boolean
[c] Object
[d] Number

[S1] This is for the solution

Q.15) Which data type is used to represent textual data in JavaScript?


*[a] String
[b] Boolean
[c] Object
[d] Number

[S1] This is for the solution

Q.16) Which data type is used to represent a collection of values in


JavaScript?
[a] String
[b] Boolean
[c] Number
*[d] Array

[S1] This is for the solution

Q.17) Which data type is used to represent absence of value in


JavaScript?
[a] Undefined
*[b] Null
[c] NaN
[d] Infinity

[S1] This is for the solution


Q.18) Which data type is used to represent a value that is not yet
assigned in JavaScript?
[a] Infinity
[b] NaN
[c] Null
*[d] Undefined

[S1] This is for the solution

Q.19) Which data type is used to represent non-numeric or invalid


numeric values in JavaScript?
*[a] NaN
[b] Undefined
[c] Null
[d] Infinity

[S1] This is for the solution

Q.20) Which data type is used to represent infinitely large or small


numbers in JavaScript?
[a] Undefined
*[b] Infinity
[c] NaN
[d] Null

[S1] This is for the solution

Q.21) What does the DOM represent in web development?


[a] Document Order Model
[b] Design Object Model
*[c] Document Object Model
[d] Data Organization Model

[S1] This is for the solution

Q.22) What is the purpose of the DOM in JavaScript?


[a] To define the structure of a web page.
*[b] To manipulate HTML elements and their properties.
[c] To handle server-side operations.
[d] To manage CSS styles and animations.

[S1] This is for the solution


Q.23) Which property allows you to access the root element of an HTML
document in JavaScript?
[a] window
[b] head
[c] body
*[d] documentElement

[S1] This is for the solution

Q.24) Which method is used to access an element by its unique identifier


(ID) in the DOM?
[a] getElementsByClassName()
[b] getElementsByTagName()
*[c] getElementById()
[d] querySelector()

[S1] This is for the solution

Q.25) How do you create a new HTML element using the DOM in JavaScript?
*[a] createElement()
[b] createNode()
[c] newElement()
[d] appendElement()

[S1] This is for the solution

Q.26) Which method is used to add a new element as a child of an


existing element in the DOM?

*[a] appendChild()
[b] insertBefore()
[c] addNode()
[d] addElement()

[S1] This is for the solution

Q.27) How do you change the text content of an HTML element using the
DOM in JavaScript?
[a] Using the innerText property.
*[b] Using the textContent property.
[c] Using the innerHTML property
[d] Using the innerText and textContent properties interchangeably.
[S1] This is for the solution

Q.28) Which method is used to access multiple elements by their class


name in the DOM?
*[a] getElementsByClassName()
[b] getElementById()
[c] getElementsByTagName()
[d] querySelectorAll()

[S1] This is for the solution

Q.29) Which method is used to remove an element from the DOM?


[a] deleteElement()
[b] removeNode()
*[c] removeChild()
[d] eraseElement()

[S1] This is for the solution

Q.30) How do you modify the CSS styles of an HTML element using the DOM
in JavaScript?
[a] Using the setAttribute() method.
[b] Using the getAttribute() method.
[c] Using the classList property.
*[d] Using the style property.

You might also like