This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
1. public class Test{ 2. public static void main( String[] argv ){ 3. // insert statement here 4. } 5. } Which statement, inserted at line 3, produces the following output?
Exception in thread �main� java.lang.AssertionError: true at Test.main(Test.java:3) // Can you explain the reason...
A. assert true; B. assert false; C. assert false : true; D. assert false == true; E. assert false: false;
When assert condition gets false, it throws AssertionError. On the right hand side of colon, you can pass any object which can be converted to String equivalent.
e.g,
assert false: new Object(); assert false: new Integer(4);
Both are legal.
In your case, true gets boxed to Boolean object. Then toString() method is called on bollean object resulting in corresponding string equivalent "true".