Computer Science

Explain Relational operator with an example.

Values & Data Types Java

29 Likes

Answer

Relational operators are used to determine the relationship between the operands. Relational operators compare their operands to check if the operands are equal to ( == ), not equal to ( != ), less than ( < ), less than equal to ( <= ), greater than ( > ), greater than equal to ( >= ) each other. The result of an operation involving relation operators is a boolean value — true or false.

Example:

int a = 8;  
int b = 10;  
boolean c = a < b;

Here, as a is less than b so the result of a < b is true. Hence, boolean variable c becomes true.

Answered By

10 Likes


Related Questions