JavaScript MCQ : JS Variables (Multiple Choice Questions)


Question 1
<!DOCTYPE html>
<html>
    <body>
        <script>
            var x = "5";
            var y = 6;
            var z = x + y;
            document.write(x + "<br>");
            document.write(y + "<br>");
            document.write(z + "<br>");
        </script>
    </body>
</html>
Guess output of the following code.
A
5 6 11
B
5 6 10
C
None of These
D
5 6 56
Question 2
<!DOCTYPE html>
<html>
    <body>
        <script>
            var num1 = 1;
            var num2 = 1;
            var num3 = "1" + num1 + num2;
            document.write(num1 + "<br>");
            document.write(num2 + "<br>");
            document.write(num3 + "<br>");
        </script>
    </body>
</html>
Guess output of the following code.
A
1 1 12
B
None of these
C
1 1 111
D
1 1 3
Question 3
<html>
    <body>
        <script>
            var x = 12.45;
            var y = 1;
            var z = '8' + x + y;
            document.write(z + "<br>");
        </script>
    </body>
</html>
Value of Z is -
A
21.451
B
813.451
C
812.451
D
21.450
Question 4
Variable declared without a value will have the value ______________.Eg.
var num;
A
undefined
B
0
C
None of these
D
null
Question 5
<html>
    
    <body>
        <script>
            var name = "John Doe";
            var name = 123;
            document.write(name + "<br>");
        </script>
    </body>

</html>
Is it possible to change the type of value after re-assignment.
A
No
B
None of these
C
Yes !! It is possible.
D
It can be possible if variable is assigned with interger value.
There are 5 questions to complete.