Java출력 결과어려움 · 30점#상속#오버라이딩#static#다형성

64. static 메서드 숨김과 super 호출

다음 Java 프로그램의 실행 결과를 쓰시오.

1class Vehicle {
2 static String type() {
3 return "V";
4 }
5
6 int wheels() {
7 return 4;
8 }
9
10 String info() {
11 return type() + wheels();
12 }
13}
14
15class Bike extends Vehicle {
16 static String type() {
17 return "B";
18 }
19
20 int wheels() {
21 return 2;
22 }
23
24 String info() {
25 return super.info() + "/" + type() + wheels();
26 }
27}
28
29public class Main {
30 public static void main(String[] args) {
31 Vehicle[] list = {new Vehicle(), new Bike()};
32 for (Vehicle x : list) {
33 System.out.println(x.type() + " " + x.info());
34 }
35 Bike b = (Bike) list[1];
36 System.out.println(b.type() + b.wheels());
37 }
38}

해설을 먼저 보면 이후 정답 시 점수가 50%만 반영됩니다.