Computer Applications
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
Related Questions
What are the different types of errors that take place during the execution of a program?
Write down the syntax of the following with reference to Java Programming:
(a) to accept an integer value using main( )
(b) to accept a fractional number using main( )
Distinguish between Syntax error and Logical error.
Explain if-else-if construct