Oracle
1Z0-851 · Question #88
1Z0-851 Question #88: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #88. The question stem and answer options stay visible for context.
Question
Given: 1. public class Plant { 2. private String name; 3. 4. public Plant(String name) { 5. this.name = name; 6. } 7. 8. public String getName() { 9. return name; 10. } 11.} 1. public class Tree extends Plant { 2. public void growFruit() { 3. } 4. 5. public void dropLeaves() { 6. } 7. } Which statement is true?
Options
- AThe code will compile without changes.
- BThe code will compile if public Tree() { Plant(); } is added to the Tree class.
- CThe code will compile if public Plant() { Tree(); } is added to the Plant class.
- DThe code will compile if public Plant() { this("fern"); } is added to the Plant class.
- EThe code will compile if public Plant() { Plant("fern"); } is added to the Plant class.
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 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.