QUESTION 14자격증/OCJP_ExamC2018. 7. 21. 17:31
Table of Contents
반응형
QUESTION 14Given:1. class One {2. public One foo() {3. return this;4. }5. }6.7. class Two extends One {8. public One foo() {9. return this;10. }11. }12.13. class Three extends Two {14. // insert method here15. }Which two methods, inserted individually, correctly complete the Three class? (Choose two.)A. public void foo() {}B. public int foo() { return 3; }C. public Two foo() { return this; }D. public One foo() { return this; }E. public Object foo() { return this; }Solution : CD
plus imformation
A. Main.java:14: foo() in Three cannot override foo() in Two;
attempting to use incompatible return type
found : void
required: One
public void foo() {}
^ 1 error
B. Main.java:14: foo() in Three cannot override foo() in Two;
attempting to use incompatible return type
found : int
required: One
public int foo() { return 3; }
^ 1 error
E. Main.java:14: foo() in Three cannot override foo() in Two;
attempting to use incompatible return type
found : java.lang.Object
required: One
public Object foo() { return this; }
^ 1 error
반응형
'자격증 > OCJP_ExamC' 카테고리의 다른 글
QUESTION 16 (0) | 2018.07.21 |
---|---|
QUESTION 15 (0) | 2018.07.21 |
QUESTION 13 (0) | 2018.07.21 |
QUESTION 12 (0) | 2018.07.21 |
QUESTION 11 (0) | 2018.07.21 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상