Fundamentals of Front End Development MCQs with Answers
Practice important Fundamentals of Front End Development MCQs with answers and explanations.
Chapter: 66
Q761:
Which method is used to set the milliseconds part of a Date object?
A. setDate()
B. setHours()
C. setMilliseconds()
D. setFullYear()
Correct Answer:
C
Chapter: 66
Q762:
Fill in the blank: Date.parse() converts a date string to the number of ________ since January 1, 1970.
A. Seconds
B. Minutes
C. Hours
D. Milliseconds
Correct Answer:
D
Chapter: 66
Q763:
What is the purpose of d.setFullYear(2024, 5, 15)?
A. Sets the year only
B. Sets the year, month, and day
C. Sets the year and day only
D. Sets the month and year only
Correct Answer:
B
Chapter: 66
Q764:
Fill in the blank: d.setDate(d.getDate() + 4) will set the date to ________ days after the current date.
A. 3
B. 4
C. 5
D. 6
Correct Answer:
B
Chapter: 66
Q765:
Which method would you use to add hours to a Date object?
A. setDate()
B. setHours()
C. setMilliseconds()
D. setFullYear()
Correct Answer:
B
Chapter: 66
Q766:
Fill in the blank: d.setMilliseconds(500) sets the milliseconds to ________.
A. 50
B. 500
C. 5000
D. 5
Correct Answer:
B
Chapter: 67
Q767:
What does an array in JavaScript allow you to do?
A. Store multiple values in a single variable
B. Store a single value in multiple variables
C. Create a new object
D. Store values in a function
Correct Answer:
A
Chapter: 67
Q768:
Fill in the blank: To create an array named cars with values "Toyota", "Honda", "BMW", you can use ________.
A. var cars = [Toyota, Honda, BMW];
B. var cars = ["Toyota", "Honda", "BMW"];
C. var cars = new Array("Toyota", "Honda", "BMW");
D. var cars = ["Toyota"; "Honda"; "BMW"];
Correct Answer:
B
Chapter: 67
Q769:
What will var fruits = ["Banana", "Orange", "Apple"]; fruits[3] = "Mango"; do?
A. Add "Mango" as the fourth element
B. Replace the second element with "Mango"
C. Add "Mango" as the first element
D. Remove the last element
Correct Answer:
A
Chapter: 67
Q770:
Fill in the blank: The statement var name = cars[0]; accesses the ________ element in the cars array.
A. First
B. Second
C. Last
D. Fourth
Correct Answer:
A
Chapter: 67
Q771:
Which method is used to sort elements in an array?
A. sort()
B. length()
C. push()
D. pop()
Correct Answer:
A
Chapter: 67
Q772:
Fill in the blank: The syntax var cars = new Array("Toyota", "Honda", "BMW"); creates an array using the ________ keyword.
A. new
B. var
C. let
D. const
Correct Answer:
A
Chapter: 67
Q773:
Which of the following statements will add "Lemon" to the end of the fruits array?
A. fruits[fruits.length] = "Lemon";
B. fruits.push("Lemon");
C. fruits.add("Lemon");
D. fruits.insert("Lemon");
Correct Answer:
A
Chapter: 67
Q774:
Fill in the blank: To access the third element in an array named myArray, use ________.
A. myArray[2]
B. myArray[3]
C. myArray[1]
D. myArray[0]
Correct Answer:
A
Chapter: 67
Q775:
What is the result of var cars = ["Toyota", "Honda", "BMW"]; cars[0] = "Audi";?
A. "Audi" replaces "Toyota"
B. Adds "Audi" to the end of the array
C. Removes "Toyota" from the array
D. No change in the array
Correct Answer:
A
Chapter: 67
Q776:
Fill in the blank: In the loop for (var index = 0; index < fruits.length; index++) { text += fruits[index]; }, the loop iterates from index ________ to ________.
A. 1, fruits.length
B. 0, fruits.length - 1
C. 1, fruits.length - 1
D. 0, fruits.length
Correct Answer:
D
Chapter: 68
Q777:
JavaScript arrays use ________ indexes, while JavaScript objects use ________ indexes.
A. Numbered, Named
B. Named, Numbered
C. String, Numbered
D. Numbered, String
Correct Answer:
A
Chapter: 68
Q778:
Fill in the blank: To create an empty array in JavaScript, it is better to use ________ instead of new Array().
A. []
B. {}
C. new Array()
D. Array()
Correct Answer:
A
Chapter: 68
Q779:
Which statement about JavaScript arrays is correct?
A. Arrays in JavaScript use named indexes
B. JavaScript arrays are best described as objects
C. Objects use numbered indexes
D. Arrays should use string indexes
Correct Answer:
B
Chapter: 68
Q780:
Fill in the blank: The isArray() function checks if a variable is an array by examining its ________.
A. Constructor
B. Length
C. Content
D. Type
Correct Answer:
A