Home > Java Programming > Assertions > Questions and Answers
01. |
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0): “assertion failedâ€; System.out.println(“finishedâ€); } } What is the result? | |||||||||||
|
02. |
Public class Foo{ public void m1( int value ){ assert 0 <= value; System.out.println( "OK" ); } public static void main( String[] args ){ Foo foo = new Foo(); System.out.print( "foo.m1( 1 ): " ); foo.m1( 1 ); System.out.print( "foo.m1( -1 ): " ); foo.m1( -1 ); } } Predict the output of code if it is assert enabled? | |||||||||||
|