Ternary (Conditional) Operators

The conditional operator (? :) is a ternary operator. This operator needs 3 operands to perform the operation.

Syntax:

Variable = <test expression> ? <expression 1> : <expression 2>


The conditional operator works as follows:

 Test Expression is Condition

 Expression 1 is Statement Followed if Condition is True

 Expression 2 is Statement Followed if Condition is False

The conditional operator (? :) is a ternary operator. This operator needs 3 operands to perform the operation.




Java : Ternary (Conditional) Operators Program List




Program [1]

Write a program using ternary operator to check whether 27 is a multiple of 3 or not.


View Solution


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad