Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 111

Given:

and the command: java Product 0

What is the result?

    Correct Answer: A

    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.

Discussion
jduarteOption: C

Answer C because the command haven´t -ea

JME_CHGOption: C

A, 0.0 > 0 is false

Huim

is no problem, answer is C.

mevltOption: A

Answer is A. assert runs where the result is false. When it is true, it will continue from the next line.

mevlt

btw it is tested.

steefaandOption: C

C is correct since program isnt run with -ea or -enableassertions and assert statement is skipped.

duydnOption: C

C is correct because we don't enable assert

lchowenOption: C

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