Oracle
1Z0-851 · Question #193
Click the Exhibit button. What two must the programmer do to correct the compilation errors? (Choose two.) 1. public class Car { 2. private int wheelCount; 3. private String vin; 4. public…
The correct answer is D. insert a call to super(vin) in the MeGo constructor E. change the wheelCount variable in Car to protected. See the full explanation below for the reasoning.
Question
Click the Exhibit button. What two must the programmer do to correct the compilation errors? (Choose two.) 1. public class Car { 2. private int wheelCount; 3. private String vin; 4. public Car(String vin){ 5. this.vin = vin; 6. this.wheelCount = 4; 7. } 8. public String drive(){ 9. return "zoom-zoom"; 10. } 11. public String getInfo() { 12. return "VIN: " + vin + " wheels: " + wheelCount; 13. } 14.} And 1. public class MeGo extends Car { 2. public MeGo(String vin) { 3. this.wheelCount = 3; 4. } 5. }
Options
- Ainsert a call to this() in the Car constructor
- Binsert a call to this() in the MeGo constructor
- Cinsert a call to super() in the MeGo constructor
- Dinsert a call to super(vin) in the MeGo constructor
- Echange the wheelCount variable in Car to protected
- Fchange line 3 in the MeGo class to super.wheelCount = 3;
How the community answered
(23 responses)- A4% (1)
- C13% (3)
- D78% (18)
- F4% (1)
Community Discussion
No community discussion yet for this question.