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