JavaScript MCQ : JS Variables (Multiple Choice Questions)


Question 1
Is it necessary to use "var" keyword while declaring variable.
A
No
B
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).
A
Square Bracket
B
Single Quote
C
None of these
D
Double Quote
Question 3
Non Initialized Variable have value "undefine", What value be printed in following case -
var carname="Volvo"; 
var carname;
A
Error
B
Volvo
C
null
D
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;
A
undefine10
B
10
C
None of these
D
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 ?
A
No Output
B
11
C
Error
D
56
There are 5 questions to complete.