상속

    <명품 JAVA Programming> - Chapter5 연습문제(9, 10, 11, 12, 13, 14)

    9. 다음 Stack 인터페이스를 상속받아 실수를 저장하는 StringStack 클래스를 구현하라. package chapter5; import java.util.Scanner; interface Stack { int length();// 현재 스택에 저장된 개수 리턴 int capacity();//스택의 전체 저장 가능한 개수 리턴 String pop();//스택의 톱(top)에 실수 저장 boolean push(String val);//스택의 톱(top)에 저장된 실수 리턴 } class StringStack implements Stack { private String[] word; private int top; public StringStack(int size) { word = new String[..

    <명품 JAVA Programming> - Chapter5 연습문제(1, 2, 3, 4, 5, 6, 7, 8)

    1. 다음 main()메소드와 실행 결과를 참고하여 상속받은 ColorTV 클래스를 작성하라. package chapter5; class TV { private int size; public TV(int size) {this.size = size;} protected int getSize() {return size;} } public class ColorTV extends TV{ private int nColors; public ColorTV(int size, int nColors) { super(size); this.nColors = nColors; } public void printProperty() { System.out.println(getSize() + "인치 " + nColors + "컬러")..