File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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??

Amir Ashfaq

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:
subject: Doubt in ExamLab question...
It's not a secret anymore!