DEVFYI - Developer Resource - FYI

What is the difference between an if statement and a switch statement?

Java Interview Questions and Answers (part 2)


(Continued from previous question...)

359. What is the difference between an if statement and a switch statement?

The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.

(Continued on next question...)

Other Interview Questions