• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt with regard to assert program

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried running it? What is w.r.t?
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
What is w.r.t?



with regard to
 
susma sahoo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Rob.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic