What will be the output of the following Java code?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);} }

🎲 Try a Random Question  |  Total Questions in Quiz: 39  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
Java Basics Practice Test: Operators — practice the complete quiz, review flashcards, or try a random question.

Here are the different types of operators in Java: Arithmetic operators: are used to perform mathematical operations on numeric values. Assignment operators: are used to assign values to variables. Relational operators: are used to compare two values and return a boolean result. Logical operators: are used to combine two or more boolean expressions and return a single boolean result. Bitwise operators: are used to perform bitwise operations on integer values. Conditional operators: are used to evaluate a condition and return one of two values based on the result of the... Show more

What will be the output of the following Java code?<br>class ternary_operator <br>{<br>public static void main(String args[]) <br>{<br> int x = 3;<br> int y = ~ x;<br> int z;<br> z = x > y ? x : y;<br> System.out.print(z);<br>} <br>}