• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Khalid mock

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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).]
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic