• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Assertion question doubt??

 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,


answer given is E........
but i think here assertion has been used appropriately throughout....
well if i give a little more thought, E may be correct because at line 18 the 2nd expression although returns a value but changes the value of local variable z, which changes the state.....may be!!!

plz have ur say on this...

thanx
amit
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can but it is not appropiate to use assersion to apply any logic that change the state of the object. think when you are running the code with assertion Off. your condition might fail but the change you were expecting doesn't take place. Keep one thing in mind...assertions are enabled while developing.Once you finish your development, the deployed application usually has assertion disabled. so in that case, your logic fails. Use assertion only for debugging option , not like a if -else block.
hope u got the point.
regards
sajid
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic