Given:
2. public class Main { 3. public static void main(String[] args) { 4. boolean earlyExit = new Main().test1(args); 5. if(earlyExit) assert false; 6. new Main().test2(args); 7. } /* w ww .java 2 s .co m*/ 8. boolean test1(String[] a) { 9. if (a.length == 0) return false; 10. return true; 11. } 12. private void test2(String[] a) { 13. if (a.length == 2) assert false; 14. } 15.}
Which are true? (Choose all that apply.)
D is correct.
This invocation will run without error.
A, B, and C are incorrect because the code compiles, and neither assertion is appropriate because ultimately they are testing the args of main()
.
E, F, and G are incorrect.
Each will throw an AssertionError.