An exercise about Assertion

Here's an exercise about Assertion:

In the following code, which lines do not use assertions appropriately?

class AssertDemo{

publicstatic Boolean message(){

System.out.println("Error!!");

returnnew Boolean("true");

}

publicstaticvoid main(String[] args){

boolean b =false;//line 11

assert b : message();//line 13

int x = -5;

assert (x+1)>0;//line 14

assert x>0 : (x = x *-1);//line 15

while(true){

System.out.println(x);

assert x-- >0;//line 19

}

}

}

Select multiple options:

A line 11

B line 13

C line 14

D line 15

E line 19

What would be your answers?

[1705 byte] By [blutch009a] at [2007-11-27 8:01:53]
# 1

> What would be your answers?

My answer would be to experiment with this on your own and find out for yourself. The exercise will do you good.

If you're confused about assertions and how to use them, check this out:

http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html

~

yawmarka at 2007-7-12 19:44:00 > top of Java-index,Java Essentials,Training...
# 2
Yup, take home finals are out.
Hippolytea at 2007-7-12 19:44:00 > top of Java-index,Java Essentials,Training...
# 3
blutch,Why are you so averse to doing your own work and getting the grade you've earned?
jverda at 2007-7-12 19:44:00 > top of Java-index,Java Essentials,Training...
# 4
hi,analyse the code, and you'll see that it compiles well. But the real problem is that the use of assertion is appropriate? Not evident
blutch009a at 2007-7-12 19:44:00 > top of Java-index,Java Essentials,Training...