Java -Conditional Statements
Java -Conditional Statements
S Sir
Simple If condition
}
If-Else condition
Sample Output:
Sun
Nested If Else statement Syntax
if(condition 1) else
{ {
// this block of statements gets executed when condition
1 is true // this block of statements get executed when
condition 1 is false
if ( condition 2) }
{
// this block gets executed when condition 1 and
condition 2 will be true
}
else
{
// this block of statements get executed when condition
1 is true and condition 2 will be false
}
}
Write a program to check whether given number is positive,
Java code
negative or zero
Sample Output:
Positive
Switch statement Syntax
switch(choice)
case value3:
{
// this block of statements get executed when choice has
value 3
case value1:
// this block of statements get executed when choice has default:
value 1
// this block of statements get executed when choice has
value other than value1, value2 and value3.
case value2:
// this block of statements get executed when choice has }
value 2
Write a program to print name of the day from the given number Java code
Sample Output:
Mon
Thank you !