• 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

Doubt in ExamLab question...

 
Ranch Hand
Posts: 173
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all...



The question is number of appropriate uses of assertions...

explanation is saying that the following usage is inappropriate ..

Here we are evaluating the argument passed to public method but we control the code that is cust value has been assigned 12,
so how this is considered as inappropriate??

Thanks
 
Greenhorn
Posts: 13
Mac Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question has its answer.. as 12 is assigned within the code and you are sure about the value of "cust" after the execution of that line , so no need for assert "cust>=20".

As Assertion means your assumption, so why you will assume that the value will be >= 20, as you yourself has assigned it 12.


hope you understand...
 
Ranch Hand
Posts: 241
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but it is not inappropriate, is it? You are assessing the value of a variable after you manipulated it, so it should be fine... I don't understand why it isn't either, Hareendra.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic