KnowledgeBoat Logo

Computer Applications

Differentiate between if else if and switch-case statements

Java Conditional Stmts

ICSE 2019

49 Likes

Answer

if else ifswitch-case
if else if can test for any Boolean expression like less than, greater than, equal to, not equal to, etc.switch-case can only test if the expression is equal to any of its case constants.
if else if can use different expression involving unrelated variables in its different condition expressions.switch-case statement tests the same expression against a set of constant values.

Answered By

34 Likes


Related Questions