Fundamentals of Front End Development MCQs with Answers
Practice important Fundamentals of Front End Development MCQs with answers and explanations.
Chapter: 58
Q681:
Which of the following is NOT a characteristic of JavaScript objects?
A. Contain named values
B. Can include methods
C. Cannot include other objects
D. Contain only primitive values
Correct Answer:
C
Chapter: 58
Q682:
Fill in the blank: An object method is an object property that contains a _____.
A. string
B. number
C. function definition
D. primitive value
Correct Answer:
C
Chapter: 59
Q683:
What does JavaScript scope define?
A. The order of function execution
B. The visibility of variables, objects, and functions
C. The speed of code execution
D. The size of the JavaScript environment
Correct Answer:
B
Chapter: 59
Q684:
What type of scope do variables declared within a JavaScript function have?
A. Global scope
B. Local scope
C. Block scope
D. Lexical scope
Correct Answer:
B
Chapter: 59
Q685:
Fill in the blank: Variables declared inside a function are ____.
A. global
B. local
C. block
D. automatic
Correct Answer:
B
Chapter: 59
Q686:
What happens if you assign a value to a variable without declaring it?
A. The variable becomes global
B. The variable becomes local
C. The code will throw an error
D. The variable will be undefined
Correct Answer:
A
Chapter: 59
Q687:
Fill in the blank: The global scope in HTML is represented by the ____ object.
A. document
B. global
C. window
D. script
Correct Answer:
C
Chapter: 59
Q688:
What is the lifetime of a local variable in JavaScript?
A. Until the page is closed
B. Until the function execution is completed
C. Until the script ends
D. Until the variable is reassigned
Correct Answer:
B
Chapter: 59
Q689:
Which scope allows access to all scripts and functions on a web page?
A. Function scope
B. Block scope
C. Local scope
D. Global scope
Correct Answer:
D
Chapter: 59
Q690:
Fill in the blank: The lifetime of a global variable starts when it is ____.
A. declared
B. assigned
C. deleted
D. accessed
Correct Answer:
A
Chapter: 59
Q691:
What happens to local variables when the function they are in completes execution?
A. They remain in memory
B. They are moved to global scope
C. They are deleted
D. They become global
Correct Answer:
C
Chapter: 59
Q692:
Which of the following is an example of an automatically global variable?
A. var x = 10;
B. y = 20;
C. let z = 30;
D. const a = 40;
Correct Answer:
B
Chapter: 59
Q693:
Fill in the blank: The global scope in JavaScript is often referred to as the ____ object.
A. global
B. window
C. document
D. scope
Correct Answer:
B
Chapter: 60
Q694:
What is an HTML event?
A. A user action or browser action
B. A type of JavaScript function
C. A method for accessing HTML elements
D. A way to declare variables in HTML
Correct Answer:
A
Chapter: 60
Q695:
Fill in the blank: JavaScript code can be executed when an event ________.
A. is declared
B. occurs
C. is logged
D. is prevented
Correct Answer:
B
Chapter: 60
Q696:
What attribute is used to handle events in HTML elements?
A. id
B. class
C. style
D. event handler attribute
Correct Answer:
D
Chapter: 60
Q697:
In the provided example, what does this.innerHTML=Date() do?
A. Changes the content of the button element
B. Changes the content of the demo element
C. Logs the current date to the console
D. Changes the background color of the button
Correct Answer:
A
Chapter: 60
Q698:
Fill in the blank: To change the content of an HTML element with an event, you can use the ________ attribute.
A. onclick
B. onmouseover
C. onload
D. onsubmit
Correct Answer:
A
Chapter: 60
Q699:
Which of the following is correct for adding an event handler to an HTML element?
A. <element event="JavaScript code">
B. <element onclick="JavaScript code">
C. <element onEvent="JavaScript code">
D. <element handle="JavaScript code">
Correct Answer:
B
Chapter: 60
Q700:
Fill in the blank: In the HTML example <button onclick="this.innerHTML=Date()">, the Date() function is used to get the ________.
A. current time
B. current date
C. name of the element
D. ID of the element
Correct Answer:
B