If activity is used when you will deal with two conditions where the first statement will get executed if the condition is true while the second one will get executed when the statement will be false. When the variable will have values then the if statement is basically used.