Sail E0 Webinar
Question


What is the output of this program?


class ternary_operator {
public static void main(String args[])
{
int x = 3;
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
}
Options:
A .  0
B .  1
C .  3
D .  -4
Answer: Option C

None.
output:
$ javac ternary_operator.java
$ java ternary_operator
3



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers