Javascript (JS) Error Handling MCQ
This section focuses on the "Javascript Error Handling" of the Javascript. These Multiple Choice Questions (mcq) should be practiced to improve the Javascript skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. What is the code snippet to go back to a history thrice?
A. history(3);
B. history(-3);
C. history.go(-3);
D. history.go(3);
View Answer
Ans : C
Explanation: The go() method loads a specific URL from the history list. The above code snippet goes back 3, like clicking the Back button thrice.
2. What will be the output of the following JavaScript code?
function myfun()
{
document.getElementById ("demo").innerHTML = Boolean(21 > 15);
}
A. true
B. false
C. error
D. 0
View Answer
Ans : A
Explanation: The boolean function returns the boolean values. Since 21 is greater than 15 the boolean function returns true.
3. What will be the output of the following JavaScript code?
function myfun()
{
document.getElementById ("demo").innerHTML = Boolean(15.00 === 15);
}
A. true
B. false
C. error
D. 0
View Answer
Ans : B
Explanation: The boolean function returns the boolean values. Since 15.00(float) is equal to 15(int) but the type is not same so the boolean function returns false.
4. What will be the output of the following JavaScript code?
var b5 = Boolean('false');
document.getElementById ("demo").innerHTML =b5;
A. true
B. false
C. error
D. undefined
View Answer
Ans : A
Explanation: The boolean function returns the boolean values. The boolean function returns true for any non empty string even if the string is false.
5. What will be the output of the following JavaScript code?
function myfun()
{
var a = "";
document.getElementById ("demo").innerHTML = Boolean(a);
}
A. true
B. false
C. error
D. undefined
View Answer
Ans : B
Explanation: When an empty string is passed to the boolean function then the function returns false. The boolean function returns true or false according to the input passed to it.
6. What will be the output of the following JavaScript code?
function myfun()
{
var a = null;
document.getElementById ("demo").innerHTML = Boolean(a);
}
}
A. true
B. false
C. error
D. undefined
View Answer
Ans : B
Explanation: The value return by the boolean method depends on the input passed to it. The NULL value when passed to the boolean function returns false.
7. The inner frame within a top-level window can be referred to as _____________
A. parent(parent)
B. parent.parent
C. parent*parent
D. parent/parent
View Answer
Ans : B
Explanation: The inner frame within a top-level window can be referred to as parent.parent
8. How are windows, tabs, iframes, and frames treated according to client-side javascript?
A. They are all browsing contexts
B. They are all browsing information
C. They are all Window contexts
D. They are all Window objects
View Answer
Ans : A
Explanation: Client-side JavaScript makes very little distinction between windows, tabs, iframes, and frames they are all browsing contexts, and to JavaScript, they are all Window objects.
9. Each tab in the single web browser window is called as ____________
A. Browsing context
B. Browser Information
C. Both Browser Information & Browsing context
D. Browser Log
View Answer
Ans : A
Explanation: Each tab in the single web browser window is called as Browsing context.
10. When will the browser invoke the handler?
A. Program begins
B. Any event occurs
C. Specified event occurs
D. None of the above
View Answer
Ans : C
Explanation: Specified event occurs will the browser invoke the handler.
Also check :
Discussion