• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Khalid mock

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which operators will always evaluate all operands?
a) | |
b) +
c) &&
d) %
e) ?:
The correct answer given is 'b' and 'd'. According to me 'e' should also be correct. Somebody please throw some light on this.
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
e is not correct
(a<b)?this will execute:if the condition isfalse>
if (a<b) evaluates to true then the part after ? evaluates, the second half does not evaluate>
but if the condition(a<b) is false , the true part will not execute >
so if does not opeate on everything
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sanjeev,
?: operator is not true because it's depend's on the condition if the condition is true then the statement immediately after the colon get's executed and the other(false) part is left untouched,therefore that part is not evaluated at all.
In the case of && same thind happen's if the first operand is false, the cursor does not evaluate the second operand.
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How can we say " + " , "always" operates both the operands.
Well, " + " in some cases is the unary operator too.
For example,
+8, +a.. etc
Please clear this point.
Hassan
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
The answer is (b) and (d)explained as follows:

Hope this clarifies..
Cheers,
Ravindra Mohan.

[This message has been edited by Ravindra Mohan (edited May 05, 2001).]
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic