Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assert question

 
patrick avery
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Master Exam I came across a question with some code containing 2 assert statements. The text of the question did not reference the assert statements and did not indicate that asserts had been enabled...it just asked "What is the result?"

2 questions:

1 - for the exam if the code contains assert statements but nothing is said about whether or not they are enabled should we assume that they are not?

2 - if asserts are not enabled does this mean they will not be executed or only that they will execute but not cause an assert exception?
 
Ruben Soto
Ranch Hand
Posts: 1032
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Patrick,

1. In Java 1.6 assertions are enabled by default at compile time, but at runtime they are disabled unless you enable them explicitly.

2. When you don't enable assertions at the java command line that means the JVM will bypass assertion code (it is as if it hadn't been coded.)
[ December 30, 2008: Message edited by: Ruben Soto ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic