2021년 가 선택하기
소프트웨어공학 선택하기
10. 다음 자바 코드에서 오류가 발생하는 문장은?
abstract class Shape {
  public void paint() { draw(); }
  abstract public void draw();
}
abstract class Circle extends Shape {
  public int radius;
  public Circle(int radius) {
    this.radius = radius; }
  double getArea() {
    return (3.14 * radius * radius); }
}
public class NamedCircle extends Circle {
  String name;
  public NamedCircle(int radius, String name) {
    super(radius);
    this.name = name;
  }
  public void draw() {
    System.out.println("반지름이 " + 
                   radius  + "인 원을 그리다.");  
  }
  public static void main(String[] args) {
    Shape s;
    s = new Shape();
    NamedCircle w = new NamedCircle(5, "Ring");
    System.out.println(w.getArea());
    w.draw();
  }
}
  • 1
     super(radius);
  • 2
     Shape s;
  • 3
     s = new Shape();
  • 4
     System.out.println(w.getArea());

위키 해설 위키해설을 등록해주세요!
문제 풀이
클릭하면 보입니다.
관련 포럼글
자유 댓글

모든 문제들의 저작권은 원저작권자에게 있습니다. 본 사이트는 웹상에 공개되어 있는 문제만 모아서 보여드립니다. 저작권 안내

copyright 2024 뉴비티::새로운 CBT 시스템 - newbt.kr 제휴 문의