Given:
and the command: java Product 0What is the result?
Given:
and the command: java Product 0What is the result?
An AssertionError is thrown because the assertion statement 'assert (price > 0);' at line n1 checks that the price must be greater than 0. Since the given command line argument is 0, the assertion fails, resulting in an AssertionError.
Answer C because the command haven´t -ea
A, 0.0 > 0 is false
is no problem, answer is C.
Answer is A. assert runs where the result is false. When it is true, it will continue from the next line.
btw it is tested.
C is correct since program isnt run with -ea or -enableassertions and assert statement is skipped.
C is correct because we don't enable assert
the assert keyword is disabled by default. To enable the assert you need to provide the "-ea" option when running java command. In this case the assert line wouldn't be evaluated. Answer is C