QUESTION 28자격증/OCJP_ExamD2018. 8. 5. 19:21
Table of Contents
반응형
QUESTION 28Click the Exhibit button.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. }And1. public class MeGo extends Car {2. public MeGo(String vin) {3. this.wheelCount = 3;4. }5. }What two must the programmer do to correct the compilation errors? (Choose two.)A. insert a call to this() in the Car constructorB. insert a call to this() in the MeGo constructorC. insert a call to super() in the MeGo constructorD. insert a call to super(vin) in the MeGo constructorE. change the wheelCount variable in Car to protectedF. change line 3 in the MeGo class to super.wheelCount = 3;Solution : DE
plus imformation
wheelCount는 class_car에서 private으로 선언되어 있다 .
그렇기 때문에 Mego 에서 wheelCount 변수를 사용하기 위해서는 Super(vin)선언 or wheelCount 접근 제한자를 체인지 .
반응형
'자격증 > OCJP_ExamD' 카테고리의 다른 글
QUESTION 30 (0) | 2018.08.05 |
---|---|
QUESTION 29 (0) | 2018.08.05 |
QUESTION 27 (0) | 2018.08.05 |
QUESTION 26 (0) | 2018.08.04 |
QUESTION 25 (0) | 2018.08.04 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상