QUESTION 54
Given:
10. public class SuperCalc {
11. protected static int multiply(int a, int b) { return a * b;}
12. }
and:
20. public class SubCalc extends SuperCalc{
21. public static int multiply(int a, int b) {
22. int c = super.multiply(a, b);
23. return c;
24. }
25. }
and:
30. SubCalc sc = new SubCalc ();
31. System.out.println(sc.multiply(3,4));
32. System.out.println(SubCalc.multiply(2,2));
What is the result?
A. 12
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 22.
F. Compilation fails because of an error in line 31.
Solution : E
Plus imformation :
Main.java:22: non-static variable super cannot be referenced from a static context
int c = super.multiply(a, b);
^ 1 error
'자격증 > OCJP_ExamA' 카테고리의 다른 글
QUESTION 56 (0) | 2018.07.08 |
---|---|
QUESTION 55 (0) | 2018.07.08 |
QUESTION 53 (0) | 2018.07.08 |
QUESTION 52 (0) | 2018.07.08 |
QUESTION 51 (0) | 2018.07.08 |
#IT #먹방 #전자기기 #일상
#개발 #일상