Please use code tags round that sort of code. The code button is below the "message" box. Is that from a book or website? If so, please quote where you got it from.
The answer is, of course, yes and no. Please tell us in which circumstances it will and in which circumstances it won't throw the AssertionError. We don't simply answer that sort of question, because you will learn lots more by working it out for yourself.
Originally posted by Paul Sturrock: What is w.r.t?
with regard to
Joined: May 22, 2008
Actually my question is if i will get this type of question in scjp exam then whether i will assume that assertion enabled before running this code. Because in that scenario only it will through asserterror otherwise it will run without any out put.
Means nothing mentioned in question about assertion enable / disable.So which one to be considered as default if there is nothing mentioned.
I got this question from some mock exam question sample.
Joined: Oct 13, 2005
Susma, I think when Paul asked what "w.r.t." meant, he was trying to warn you against using such abbreviations. To those of us who grew up speaking English it is obvious, but there are lots of JavaRanch users who aren't familiar with that sort of abbreviation, so please spell all words out in full.
I think you are correct; you get an AssertionError only when assertions are enabled (with the -ea option). Please tell us which source you got that mock question from. I think such a question would be regarded as unfair, without your being told whether assertions are enabled, so I don't think you need to worry on that point. You might get more information if you read the posts on the SJCP forum here at JavaRanch.