Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Dan's Tests | Question from 'Conditional Operator'  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have come across following question from Dan's operator section tests:
________________________________________________________________________

What is the result of attempting to compile and run the above program?
a. Prints: false,false,false
b. Prints: false,false,true
c. Prints: false,true,false
d. Prints: false,true,true
e. Prints: true,false,false
f. Prints: true,false,true
g. Prints: true,true,false
h. Prints: true,true,true
i. Runtime error
j. Compiler error
k. None of the above
__________________________________________________________________________
Now, based on the operator precedence and operator evaluation rules, '&&' has got a higher precedence than '||'. So, according to me, these should be the order of steps executed at runtime:
[LIST]
 
Ranch Hand
Posts: 8934
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

&&' has got a higher precedence than '||'


True.
 
Nidhi Bangur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer to my other thread. The question is incomplete here. I think that it got posted by mistake.
Thanks,
Nidhi.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where is your other thread? can u link it here?
I thought it will be "false, true, true"too... but I compile and run the code and it's true, false, false.
 
Nidhi Bangur
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Edward,
Here is the link to my other thread: http://www.coderanch.com/t/243252/java-programmer-SCJP/certification/Dan-Tests-Conditional-Operator
-Nidhi.
 
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!