JavaScript MCQ : JS Variables (Multiple Choice Questions)
Question 1 |
Is it necessary to use "var" keyword while declaring variable.
No | |
Yes |
Question 1 Explanation:
We can skip "var" keyword but initialization is mandatory after skipping "var" keyword.
Question 2 |
When you assign a text value to a variable, we put text value in the pair of _________.Select appropriate option(s).
Square Bracket | |
Single Quote | |
None of these | |
Double Quote |
Question 3 |
Non Initialized Variable have value "undefine", What value be printed in following case -
var carname="Volvo"; var carname;
Error | |
Volvo | |
null | |
undefined |
Question 3 Explanation:
If you re-declare a JavaScript variable, it will not lose its value.
Question 4 |
What will be the value of Variable - "num3" ?
var num1; var num2 = 10; var num3 = num1 + num2;
undefine10 | |
10 | |
None of these | |
undefine |
Question 4 Explanation:
Undefine + Any Value = Undefine
Question 5 |
<html> <body> <script> var x = 5; var y = 6; document.write((x + y) + "<br>"); </script> </body> </html>What will be the output of the following code ?
No Output | |
11 | |
Error | |
56 |
There are 5 questions to complete.