Computer Science
Write short notes on Control statement
Java Conditional Stmts
12 Likes
Answer
The order in which the statements of a program are executed is known as control flow. By default, the statements of a program are executed from top to bottom in order in which they are written. But most of the times our programs require to alter this top to bottom control flow based on some condition. The statements that enable us to alter the control flow of the program are known as control statements. Control flow can be altered in the following two ways:
- Bi-Directional flow of control
In Bi-Directional flow of control, control flow is transferred to one set of statements if the condition is true and to a different set of statements if the condition is false. We can perform Bi-Directional flow of control using if and if-else statements. - Multiple Branching of control
In Multiple Branching of control, multiple conditions are tested and then control flow is transferred to that branch (comprising of a particular set of statements) whose condition tests true. We can perform Multiple Branching of control using if-else-if ladder and switch-case statements.
Answered By
3 Likes
Related Questions
Write short notes on Looping statement
What are the different ways to input the values in a Java Programming? Name them
What is meant by statement? Name the different types of statements which are used in Java programming.
What is the purpose of default in a switch statement? Explain with the help of an example.