1 is an odd number. 2 is an even number. 3 is an odd number. 4 is an even number. 5 is an odd number. 6 is an even number. 7 is an odd number. 8 is an even number. 9 is an odd number. 10 is an even number.

Using conditional operator

Now let’s see a java program to check even or odd using conditional operator.

Conditional operator (ternary operator) is used instead of if and else.