Saturday, 17 October 2020

What returns by "if" Condition Statement in Java ?

What returns by "if" Condition Statement in Java ? 

 Answer: - "if" condition returns a true which is a boolean data when condition is true and provide false which also is a boolean when condition is false. 

Example Code is here:

import java.util.*;
public class ReturnofIf {
public static void main(String[] args) throws java.io.IOException
{
boolean tf;                 //boolean tf is maid
if(tf = (char) System.in.read() >= 'M') 
{
System.out.println("Given Value is:" +tf);
}
else
{
System.out.println("Given Value is:" +tf);
}
}
}


_________________________________________________________________________________ 

Input : A 
Output : Given Value is:false 

Input : N 
Output : Given Value is:true