QUESTION 7자격증/OCJP_ExamD2018. 7. 29. 16:14
Table of Contents
반응형
QUESTION 7Click the Exhibit button.10. interface Foo{11. int bar();12. }13.14. public class Beta {15.16. class A implements Foo {17. public int bar(){ return 1; }18. }19.20. public int fubar(Foo foo){ return foo.bar(); }21.22. public void testFoo(){23.24. class A implements Foo{25. public int bar(){return 2;}26. }27.28. System.out.println(fubar(new A()));29. }30.31. public static void main(String[] args) {32. new Beta().testFoo();33. }34. }Which three statements are true? (Choose three.)A. Compilation fails.B. The code compiles and the output is 2.C. If lines 16, 17 and 18 were removed, compilation would fail.D. If lines 24, 25 and 26 were removed, compilation would fail.E. If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.F. If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.Solution : BEF
plus imformation
Main 문 : Beta 클래스 --> testFoo 메소드 실행 --> testFoo 메소드는 return 값으로 2 를 반환 (B)
class A 는 동일한 interface Foo를 사용한다 ( implement )
public int fubar 는 return 으로 공용으로 사용되는 interface Foo의 int bar 를 반환
return 을 통해 1,2 를 각각 반환해주는 곳을 지워 주게 된다면 남아 있는 return 의 값으로 결과 값이 나옴 ( E, F )
반응형
'자격증 > OCJP_ExamD' 카테고리의 다른 글
QUESTION 9 (0) | 2018.07.29 |
---|---|
QUESTION 8 (0) | 2018.07.29 |
QUESTION 6 (0) | 2018.07.29 |
QUESTION 5 (0) | 2018.07.29 |
QUESTION 4 (0) | 2018.07.26 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상