Final answer:
An if statement is used to make a decision based on a single condition, an else-if statement checks alternate conditions if the first is false, and a switch-case construct is used when there are multiple values to compare against.
Step-by-step explanation:
An if statement is used to make a decision based on a single condition. It checks if a condition is true, and if so, executes a block of code. For example, if a student's score is above a certain value, they pass the exam:
if (score >= passingScore) {
System.out.println("Pass");
}
An else-if statement is used to provide alternate conditions to check if the first condition is false. It allows for multiple conditions to be evaluated sequentially. For example, if the score is not passing, but exceeds the minimum to be eligible for a retest:
else if (score >= retestMinimum) {
System.out.println("Eligible for retest");
}
A switch-case construct is used when you have multiple possible values to compare against. It allows for concise code organization and can handle multiple conditions in an efficient way. For example, using a switch-case to determine the day of the week:
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
...
}