KnowledgeBoat Logo

Computer Applications

Explain if-else construct

Input in Java

18 Likes

Answer

In if-else construct, the user defines the statements to be executed when the condition results in true or false. If the given condition results in true, the statements in the 'if' block are executed and if the given condition results in false, the statements in the 'else' block are executed.

The syntax of if-else construct is as follows:

if(condition)
Statement 1     //executed if condition is true
else
Statement 2     //executed if condition is false

Answered By

13 Likes


Related Questions