Q. Which one of the following also known as Conditional Expression:

  • (A) Alternative to if-else
  • (B) Switch statement
  • (C) If-then-else statement
  • (D) immediate if
πŸ’¬ Discuss
βœ… Correct Answer: (D) immediate if
Explanation: A conditional expression can only evaluate two things, which either true or false, that are purely based on the evaluation of the condition

Q. In JavaScript, what is a block of statement?

  • (A) Conditional block
  • (B) block that combines a number of statements into a single compound statement
  • (C) both conditional block and a single statement
  • (D) block that contains a single statement
πŸ’¬ Discuss
βœ… Correct Answer: (B) block that combines a number of statements into a single compound statement
Explanation: A block of statement can be understand as the set of the zero or more statements. In general, a block of statement has common definition "which combines one or a number of statements into a single statement for ease.

Q. When interpreter encounters an empty statements, what it will do:

  • (A) Shows a warning
  • (B) Prompts to complete the statement
  • (C) Throws an error
  • (D) Ignores the statements
πŸ’¬ Discuss
βœ… Correct Answer: (D) Ignores the statements
Explanation: In JavaScript, when the interpreter encounters a empty statements it normally ignores or not response to that empty statement. The empty statements also sometimes very useful like we use the empty statements for creating loop for nothing.

Q. The "function" and " var" are known as:

  • (A) Keywords
  • (B) Data types
  • (C) Declaration statements
  • (D) Prototypes
πŸ’¬ Discuss
βœ… Correct Answer: (C) Declaration statements

Q. In the following given syntax of the switch statement, the Expression is compared with the labels using which one of the following operators?

Code:
switch(expression)  
{  
    statements  
}  
  • (A) ===
  • (B) equals
  • (C) ==
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) ===

Q. What will happen, if the following JavaScript code is executed?

Code:
var count =0;  
while (count <10)  
{  
     console.log(count);  
     count++;  
}  
  • (A) An error is displayed
  • (B) An exception is thrown
  • (C) The values of count variable are logged or stored in a particular location or storage
  • (D) The value of count from 0 to 9 is displayed in the console
πŸ’¬ Discuss
βœ… Correct Answer: (C) The values of count variable are logged or stored in a particular location or storage

Q. Which of the following is the correct output for the following JavaScript code:

Code:
Int x=8;  
if(x>9)  
{  
document.write(9);  
}  
else  
{  
document.write(x);  
}  
  • (A) 9
  • (B) 0
  • (C) 8
  • (D) Undefined
πŸ’¬ Discuss
βœ… Correct Answer: (C) 8

Q. Which of the following is the correct output for the following JavaScript code

Code:
var grade='C';  
var result;  
switch(grade)  
{  
case'A':  
{  
        result+="10";  
break;  
}  
case'B':  
{  
        result+=" 9";  
break;  
}  
case'C':  
{  
        result+=" 8";  
break;  
}  
default:  
    result+=" 0";  
}  
document.write(result);  
  • (A) 10
  • (B) 9
  • (C) 8
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (C) 8

Q. Which of the following is the correct output for the following JavaScript code:

Code:
var grade='D';  
var result;  
switch(grade)  
{  
case'A':  
        result+="10";  
case'B':  
        result+=" 9";  
case'C':  
        result+=" 8";  
case 'D'  
result+=" 6";  
default:  
        result+=" 0";  
}  
document.write(result);  
  • (A) 10
  • (B) 6
  • (C) 33
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (B) 6

Q. Which of the following is the correct output for the following JavaScript code:

Code:
var x=3;  
var y=2;  
var z=0;  
If(x==y)  
document.write(x);  
elseif(x==y)  
document.write(x);  
else  
document.write(z);  
  • (A) 3
  • (B) 0
  • (C) Error
  • (D) 2
πŸ’¬ Discuss
βœ… Correct Answer: (B) 0