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
None of These
C
5 6 10
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 111
B
1 1 3
C
1 1 12
D
None of these
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
813.451
B
21.451
C
21.450
D
812.451
Question 4
Variable declared without a value will have the value ______________.Eg.
var num;
A
0
B
None of these
C
null
D
undefined
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
It can be possible if variable is assigned with interger value.
B
No
C
Yes !! It is possible.
D
None of these
There are 5 questions to complete.