File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in ExamLab question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in ExamLab question..." Watch "Doubt in ExamLab question..." New topic
Author

Doubt in ExamLab question...

Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

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
Amir Ashfaq
Greenhorn

Joined: Feb 25, 2011
Posts: 13

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...
Chandella Montero
Ranch Hand

Joined: Feb 18, 2011
Posts: 89
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.


OCA, OCP Java 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in ExamLab question...