Oracle
1Z0-819 · Question #146
1Z0-819 Question #146: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #146. The question stem and answer options stay visible for context.
Question
Given:
public class Price {
private final double value;
public Price(String value) {
this(Double.parseDouble(value));
}
public Price(double value) {
this.value = value;
}
public Price () {
public double getValue() { return value; }
public static void main(String[] args) {
Price p1 = new Price("1.99");
Price p2 = new Price();
Price p3 = new Price(2.99);
System.out.println(p1.getValue()+"-"+p2.getValue()+"-"+p3.getValue());
}
}
What is the result?
Options
- AThe compilation fails.
- B1.99-2.99-
- C1.99-2.99-0.0
- D1.99-0.0-2.99
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.