..
EaxmA QUESTION 33
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

QUESTION 33

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.



Correct Answer: E


main 클래스(30~32)를 순차적으로 따라가 보자.

SubCalc sc = new SubCalc (); 으로 객체 생성

sc의 multiply 메소드 실행

21 라인에서 multiply 메소드는 static으로 선언


'DEV > ocjp' 카테고리의 다른 글

EaxmA QUESTION 35  (0) 2015.02.10
EaxmA QUESTION 34  (0) 2015.02.10
EaxmA QUESTION 23  (0) 2015.02.10
  Comments,     Trackbacks