Interview Question in Java


 

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

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

by ksk
VoteNowAnswers to "What is the difference between a switch statement and an if statement?"

 If statement is used to select from two alternatives. It uses a boolean expression to decide which alternative should be executed. The expression in if must be a boolean value. The switch statement is used to select from multiple alternatives. The case values must be promoted to an to int value.

 
by ksk

The main diffrence is Switch is more faster than the if.

by niket