QUESTION 5자격증/OCJP_ExamC2018. 7. 21. 16:12
Table of Contents
반응형
QUESTION 5Given:10. interface A { void x(); }11. class B implements A { public void x() {} public void y() {} }12. class C extends B { public void x() {} }And:20. java.util.List<A> list = new java.util.ArrayList<A>();21. list.add(new B());22. list.add(new C());23. for (A a : list) {24. a.x();25. a.y();26. }What is the result?A. The code runs with no output.B. An exception is thrown at runtime.C. Compilation fails because of an error in line 20.D. Compilation fails because of an error in line 21.E. Compilation fails because of an error in line 23.F. Compilation fails because of an error in line 25.Solution : F
plus imformation
Main.java:25: cannot find symbol
symbol : method y()
location: interface A
a.y();
^
1 error
반응형
'자격증 > OCJP_ExamC' 카테고리의 다른 글
QUESTION 7 (0) | 2018.07.21 |
---|---|
QUESTION 6 (0) | 2018.07.21 |
QUESTION 4 (0) | 2018.07.20 |
QUESTION 3 (0) | 2018.07.20 |
QUESTION 2 (0) | 2018.07.19 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상