0% found this document useful (0 votes)
2 views

Lesson 7 - Conditional Statements in Java

The document provides an overview of conditional statements in Java, detailing their purpose in controlling program execution based on boolean conditions. It covers various types of conditional statements, including if, if-else, and nested if statements, along with their syntax. The document emphasizes the functionality of these statements in executing specific actions based on the evaluation of conditions.

Uploaded by

k.anany1750
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lesson 7 - Conditional Statements in Java

The document provides an overview of conditional statements in Java, detailing their purpose in controlling program execution based on boolean conditions. It covers various types of conditional statements, including if, if-else, and nested if statements, along with their syntax. The document emphasizes the functionality of these statements in executing specific actions based on the evaluation of conditions.

Uploaded by

k.anany1750
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Conditional Statements

in Java
Topics to be covered
1. Introduction to Conditional Statements
2. Types of Conditional Statements
a. if statement
b. Multiple use of if
c. if-else statement
d. Nested if statement
Mind Map

Control Statements

Sequential Conditional Iterative


Statements Statements Statements
Sequential Statements
Conditional Statements
Selection statements allow us to control the flow of program execution
on the basis of the conditions. The condition is an expression that
returns a boolean value.

Selection statements can be divided into the following categories:


a. The if statement
b. Multiple of if
c. The if-else statement
d. The if-else-if statement
if Conditional Statement
The if statement only executes when the specified condition is true. If
the condition is false and there is not else keyword then the first
contained statement will be skipped and execution continues with the
rest of the program.
The syntax is :
if(condition)
{
Set of statements;
}
if and only if Conditional Statement
The if and only if statement is used where two or more actions to be
performed depending upon the conditions.

The syntax is :
if(condition)
{
Set of statements;
}
if(condition)
{
Set of statements;
}
if else Conditional Statement
The if else statement only executes when either of the two actions are
to be performed depending upon certain conditions.
The syntax is :
if(condition)
{
Set of statements;
}
else
{
Set of statements;
}
if else if else Statement
It works with multiple conditions. Whenever the condition is true,
the associated statement will be executed and the remaining
conditions will be bypassed. If none:of the conditions are true then
the else block will execute The syntax is ->
if(condition)
statements;
else if (condition)
statements;
else if(condition)
statement;
else
statements;
if else if else Statement

You might also like