+ 13

Do Conditional Operators have precedence?

i come across a question in submissions about these operator's != , || , && having precedence in java. i know that maths operators do but i have never heard of conditional operator's having them before? i choose false but apparently i was wrong?

7th Feb 2018, 9:24 AM
D_Stark
D_Stark - avatar
11 ответов
+ 23
yes /*i submitted a good quiz on that but was declined saying "so many quizzes of this type already exist" 😂*/
7th Feb 2018, 10:15 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 23
yaa we have that type of quiz in C++ guess what I just played ...😂😂😂 cout<<!(1||0&&!1) //output :- 0
7th Feb 2018, 10:30 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 19
true||false&&false //answer will be true , but most ppl do it as false 😅 //so i made this as quiz
7th Feb 2018, 10:24 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 17
it will be treated as true||(false&&false) ..... true||false ... ie true //bcz precedence of && is greater than that of || @David
7th Feb 2018, 10:43 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
@Cool Coding Thank you very much! i do wonder though why i have only just learned this now. 🤔
7th Feb 2018, 9:51 AM
D_Stark
D_Stark - avatar
+ 10
@ Gaurav did you make code quiz about it? if so can i have a look at it ? 😀
7th Feb 2018, 10:22 AM
D_Stark
D_Stark - avatar
+ 8
Thank you very much Gaurav thats perfect 👍👍👍👍
7th Feb 2018, 10:49 AM
D_Stark
D_Stark - avatar
+ 7
@ Gaurav can you explain to me how i should read true||false&&false i have never seen this before whats going on with me haha 😨 thanks
7th Feb 2018, 10:36 AM
D_Stark
D_Stark - avatar
+ 7
🤔 now im unsure what answer is right is there anyway to see step by step execution of this exspression? thanks
8th Feb 2018, 11:47 PM
D_Stark
D_Stark - avatar
+ 2
true||false&&false..... The answer is false. The checking starts from left to right and not according to precedence. While checking from left to right the execution takes place in this way.... 👇 (true||false)&&false true&&false false I took help of parentheses just to explain you... Thank you.
8th Feb 2018, 10:50 AM
Nashat
Nashat - avatar