In the following switch syntax, the expression is compared with the case labels using which of the following operator(s)? [code] switch(express

Lâm Phung

New member
In the following switch syntax, the expression is compared with the case labels using which of the following operator(s)?
Code:
switch(expression)
{
    statements
}
A. ==
B. equals
C. equal
D. ===
 
Answer: d
Explanation: A strict comparison (e.g., ===) is only true if the operands are of the same type and the contents match. When a switch executes, it computes the value of the expression and then looks for a case label whose expression evaluates to the same value (where sameness is determined by the === operator).
 

Tìm kiếm

Back
Top