I hope you're all doing well! I'm currently preparing for the OCA/OCP Java Programmer Certification and I've come across a question regarding the behavior of the ternary operator that I find a bit confusing.
In the following code snippet:
Code: Select all
Double d = 10.0;
Byte by = 1;
Number n = a == b ? d : by;
slice masters
Could someone please clarify why the expression behaves this way and how I can ensure it returns a Number? Any insights or explanations would be greatly appreciated!
Thanks in advance!