Given:
What is the result?
Given:
What is the result?
The code does not compile because the final variable 'value' is not initialized in every constructor. In Java, a final variable must be initialized at the time of declaration or in every constructor. Since the default (no-argument) constructor 'public Price()' does not initialize the final variable 'value', the compilation fails.
Correct answer is C public Price() {}: The blank final field value may not have been initialized
C is correct, final variable not initialized when is created, must be initialialized in every contructor or call this() other constructor that do it
Tested C. "invalid method declaration; return type required" lines: 3, 5 and 7.
There's no constructor with zero arguments.
My bad. It doesn't compile because the final variable must be set in every constructor.
Answer: C
Correct answer is C