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

Java Script MCQ Set Paper 4

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java Script MCQ Set Paper 4

Uploaded by

Prajwal Samshi
Copyright
© © All Rights Reserved
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 function in JavaScript?


[a] A built-in JavaScript object.
*[b] A statement that performs a specific task.
[c] A variable that holds a single value.
[d] A collection of properties and methods.

[S1] This is for the solution

Q.2) How do you define a function in JavaScript?


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

[S1] This is for the solution

Q.3) What is the purpose of parameters in a function?


[a] They define the return value of the function.
*[b] They store the values that the function will work with
[c] They determine the scope of the function.
[d] They control the visibility of the function.

[S1] This is for the solution

Q.4) How do you call a function in JavaScript?


[a] call myFunction()
[b] execute myFunction()
[c] run myFunction()
*[d] myFunction()

[S1] This is for the solution

Q.5) What is the return statement used for in a function?

[a] To define the parameters of the function.


*[b] To specify the value to be returned by the function.
[c] To declare local variables within the function.
[d] To terminate the function execution.

[S1] This is for the solution

Q.6) Which of the following is true about function expressions in


JavaScript?
[a] They are hoisted to the top of the scope.
[b] They cannot be assigned to variables.
[c] They are only used for arrow functions.
*[d] They are defined within another expression or statement.
[S1] This is for the solution

Q.7) What is the difference between function declarations and function


expressions in JavaScript?
*[a] Function declarations are hoisted, while function expressions are
not.
[b] Function expressions can be named, while function declarations
cannot.
[c] Function declarations are used for asynchronous operations, while
function expressions are used for synchronous operations.
[d] There is no difference; the terms can be used interchangeably.

[S1] This is for the solution

Q.8) Which keyword is used to invoke a function recursively in


JavaScript?
[a] recurse
[b] call
[c] invoke
*[d] arguments

[S1] This is for the solution

Q.9) What is a callback function in JavaScript?

[a] A function that is executed immediately.


[b] A function that is executed in reverse order.
*[c] A function that is passed as an argument to another function and is
invoked later.
[d] A function that returns another function.

[S1] This is for the solution

Q.10) What is the purpose of the arguments object in JavaScript?


[a] It stores the local variables of a function.
[b] It determines the scope of a function.
[c] It controls the visibility of a function.
*[d] It represents the list of parameters passed to a function.

[S1] This is for the solution

Q.11) What is an object in JavaScript?


[a] A data type used to store numbers.
[b] A special function that returns a value.
*[c] A collection of key-value pairs.
[d] A loop construct used for iteration.

[S1] This is for the solution


Q.12) How do you create an object in JavaScript?
*[a] Using the {} curly braces.
[b] Using the new Object() syntax.
[c] Using the createObject() function.
[d] Using the object() keyword.

[S1] This is for the solution

Q.13) Which of the following is a valid way to access a property of an


object in JavaScript?
[a] object[property]
[b] object.property
*[c] Both a and b.
[d] Neither a nor b.

[S1] This is for the solution

Q.14) How do you add a new property to an existing object in JavaScript?


[a] Using the addProperty() function.
*[b] Using the object.property = value syntax.
[c] Using the newProperty keyword.
[d] Using the appendProperty() method.

[S1] This is for the solution

Q.15) How do you remove a property from an object in JavaScript?


*[a] Using the delete keyword.
[b] Using the removeProperty() function.
[c] Using the object.property = null assignment.
[d] Using the remove() method.

[S1] This is for the solution

Q.16) How do you iterate over the properties of an object in JavaScript?


[a] Using the forEach() method.
[b] Using the map() function.
*[c] Using a for loop.
[d] Objects cannot be iterated over.

[S1] This is for the solution

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


*[a] It refers to the current object within a method.
[b] It refers to the global object.
[c] It refers to the parent object of the current object.
[d] It refers to a specific property of an object.

[S1] This is for the solution


Q.18) How do you check if a property exists in an object?
[a] Using the propertyExists() function.
[b] when your ready drop a mail for remock
*[c] Using the hasOwnProperty() method.
[d] Using the object.property !== undefined comparison.

[S1] This is for the solution

Q.19) Which of the following is true about objects in JavaScript?


*[a] Objects can have methods that perform actions.
[b] Objects can only store primitive data types.
[c] Objects cannot be passed as arguments to functions.
[d] Objects can only have a single property.

[S1] This is for the solution

Q.20) What is JSON (JavaScript Object Notation)?


[a] A way to define comments in JavaScript code
[b] A method for including external JavaScript files.
[c] A type of object used for handling date and time.
*[d] A data interchange format that uses object-like syntax.

[S1] This is for the solution

Q.21) What is an array in JavaScript?


*[a] A data structure used to store multiple values in a single
variable.
[b] A function that performs a specific task.
[c] A loop construct used for iteration.
[d] A built-in JavaScript object.

[S1] This is for the solution

Q.22) How do you create an array in JavaScript?

[a] Using the array() keyword.


[b] Using the {} curly braces.
*[c] Using the new Array() syntax.
[d] Using the createArray() function.

[S1] This is for the solution

Q.23) How do you access an element in an array?

[a] Using the element() function.


*[b] Using the array index within square brackets.
[c] Using the get() method.
[d] Using the getElement() keyword

[S1] This is for the solution


Q.24) How do you add a new element to the end of an array in
JavaScript?
*[a] Using the push() method.
[b] Using the add() function.
[c] Using the append() keyword.
[d] Using the addElement() method.

[S1] This is for the solution

Q.25) How do you remove the last element from an array in JavaScript?
[a] Using the remove() method.
*[b] Using the pop() method.
[c] Using the delete() keyword.
[d] Using the removeElement() function.

[S1] This is for the solution

Q.26) How do you find the length of an array in JavaScript?

[a] Using the size() function.


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

[S1] This is for the solution

Q.27) How do you iterate over the elements of an array in JavaScript?


*[a] Using a for loop.
[b] Using the forEach() method.
[c] Using the map() function.
[d] Arrays cannot be iterated over.

[S1] This is for the solution

Q.28) How do you check if a value exists in an array?


[a] Using the find() method.
*[b] Using the indexOf() method.
[c] Using the contains() function.
[d] Using the checkValue() keyword.

[S1] This is for the solution


Q.29) Which of the following is a valid way to create an empty array in
JavaScript?

[a] var array = new Array();


[b] var array = [];
*[c] Both a and b.
[d] Neither a nor b.

[S1] This is for the solution

Q.30) What is the purpose of the splice() method in JavaScript arrays?


[a] To concatenate two or more arrays.
[b] To sort the elements of an array in ascending order.
*[c] To remove elements from an array and optionally replace them with
new elements.
[d] To reverse the order of the elements in an array.

[S1] This is for the solution

You might also like