File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt with regard to assert program

 
susma sahoo
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried running it? What is w.r.t?
 
Campbell Ritchie
Sheriff
Pie
Posts: 47262
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
What is w.r.t?


with regard to
 
susma sahoo
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47262
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47262
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Rob.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic