Relation Operator in Java and example

 

Relation Operator in Java

 

Q.1 )  type of relations operator and syntax?

1.       Is Less then [  syntax:- <]

2.       Is Less then or equal to[  syntax:- <=]

3.       Is GreaterThan [ syntax:- >]

4.       Is GreaterThan or equal to [ syntax:- >]

5.       Is equaln to [syntax:- ==]

6.       Is notequal to [syntax:- !=]

Q.2) write a program of implementing of relation operator?

Programm:-

       class  Relational

{

Public static void main(String args[])

{
int  x,y;

X=10;

Y=6;

System.out.println(“value is” + (x>y));

System.out.println(“value is” + (x>=y));

System.out.println(“value is” + (x<y));

System.out.println(“value is” + (x<=y));

System.out.println(“value is” + (x==y));

System.out.println(“value is” + (x!=y));

}

}

Output

Note- at first compile this programm then you run

Javac  Relational.java

Java  Relational

Value   is = false

Value   is = false

Value   is  = true

Value   is =true

Value   is =false

Value   is =true

 


Post a Comment

0 Comments