Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's Tests | Question from 'Conditional Operator' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's Tests | Question from 'Conditional Operator'

Nidhi Bangur
Greenhorn

Joined: Sep 12, 2003
Posts: 19
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]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

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

True.


Groovy
Nidhi Bangur
Greenhorn

Joined: Sep 12, 2003
Posts: 19
Please refer to my other thread. The question is incomplete here. I think that it got posted by mistake.
Thanks,
Nidhi.
Ed Tse
Ranch Hand

Joined: Sep 18, 2003
Posts: 183
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.


SCJP, Pre-SCJD (URLyBird 1.3.1), Teradata Cert'd Prof
Nidhi Bangur
Greenhorn

Joined: Sep 12, 2003
Posts: 19
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Dan's Tests | Question from 'Conditional Operator'
 
Similar Threads
Dan's Tests | Question from 'Conditional Operator'
Dan's || && question
Dan's exam
Dan's Question : Fundamental Classes
Doubts in Dan's Exam: