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 with regard to assert program 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 with regard to assert program" Watch "Doubt with regard to assert program" New topic
Author

Doubt with regard to assert program

susma sahoo
Greenhorn

Joined: May 22, 2008
Posts: 4

So please confirm what will be the output for this program.It will throw asserterror or not.Or it will run without any out put

Thanks
[ May 27, 2008: Message edited by: Rob Prime ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have you tried running it? What is w.r.t?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
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.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3446
    
  12
Originally posted by Paul Sturrock:
What is w.r.t?


with regard to


Joanne
susma sahoo
Greenhorn

Joined: May 22, 2008
Posts: 4
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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
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.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Changed the topic title to make it clear, so no more discussions about that.

I also added the code blocks so it's easier to read.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
Thank you, Rob.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt with regard to assert program