Which statement is true?

Given:

11. public void go(int x) {
12. assert (x > 0);
13. switch(x) {
14. case 2: ;
15. default: assert false;
16. }
17. }
18. private void go2(int x) { assert (x < 0); }

Which statement is true?

Given:

11. public void go(int x) {
12. assert (x > 0);
13. switch(x) {
14. case 2: ;
15. default: assert false;
16. }
17. }
18. private void go2(int x) { assert (x < 0); }

Which statement is true?

A.
All of the assert statements are used appropriately.

B.
Only the assert statement on line 12 is used appropriately.

C.
Only the assert statement on line 15 is used appropriately.

D.
Only the assert statement on line 18 is used appropriately.

E.
Only the assert statements on lines 12 and 15 are used appropriately.

F.
Only the assert statements on lines 12 and 18 are used appropriately.

G.
Only the assert statements on lines 15 and 18 are used appropriately.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Matti

Matti

G is correct, assert in line 12 is used in a public method and checked at begin of method!