목록Java (30)
archive

1. 인터페이스 상속 - 인터페이스도 다른 인터페이스를 상속할 수 있으면, 클래스와는 달리 다중 상속을 허용한다. -다음과 같이 extends 키워드 뒤에 상속할 인터페이스들을 쉼표로 구분해서 나열하면 된다. public interface 자식인터페이스 extends 부모인터1, 부모인터2 {...} - 자식 인터페이스의 구현 클래스는 자식 인터페이스의 메소드 뿐만 아니라 부모 인터페이스의 모든 추상 메소드를 재정의해야한다. -구현 객체는 자식 및 부모 인터페이스 변수에 대입이 가능하다 -구현 객체가 자식 인터페이스 변수에 대입되면 자식 및 부모 인터페이스의 추상 메소드를 모두 호출할 수 있으나, 부모 인터페이스 변수에 대입이 된다면 부모 인터페이스에 선언된 추상 메소드만 호출이 가능하다. 2. 타입 변..

1. 인터페이스 역할 (시험 서술형 예상) - ***** 수업시간에 교수님 설명 듣고 정리하기 2. 인터페이스 구현 -인터페이스는 .java 형태의 소스파일로 작성이 되고 .class 형태로 컴파일이 되기 때문에 물리적인 형태는 클래스와 동일, 소스 작성 시 선언하는 방법과 구성 멤버가 클래스와 다름 -인터페이스 선언 시 접근제한자는 클래스와 마찬가지로 같은 패키지 내에서만 사용이 가능한 default, 패키지와 상관없이 사용하는 public을 붙일 수 있음 -인터페이스가 가질 수 있는 멤버의 종류 1) public 상수 필드 2) public 추상 메소드 -> 추상 메소드란, 선언부만 있고 실행부인 중괄호가 없는 메소드를 말한다. 3) public 디폴트 메소드 4) public 정적 메소드 5) pr..

We want to construct the Calculator, Calc, Add, Sub, Mul, and Div classes in order for the attached main method to work properly. • Calculator has one Calc field. • The setCalculator method of Calculator takes one parameter and can receive Add, Sub, Mul, and Div objects as parameters. When each object is received, it can be set as the field. • The run method of Calculator receives two integers t..
1. 자동 타입 변환 (Promotion) - 자동적으로 타입 변환이 일어나는 것 - 자동 타입 변환이 일어날 조건 부모타입 변수 = 자식타입객체 ; 즉, 자식타입의 객체가 상위 타입인 부모타입의 변수에 대입되는 경우 자동 타입 변환이 일어남 - 자식은 부모의 특징과 기능을 상속받기 때문에 부모와 동일하게 취급될 수 있음, 예를들어 고양이가 동물의 특징과 기능을 상속받았다면 '고양이는 동물이다' 가 성립하게 된다. - 따라서 Cat 객체를 Animal 타입의 변수에 대입하면 자동 타입 변환이 일어난다. Cat cat= new Cat(); Animal animal=cat; //cat은 자동 타입 변환이 일어나 Animal 타입의 변수 animal에 대입이 가능해진다. - Animal animal=new C..

The Point class and the main method is as follows. Implement the ColorPoint class and the Point3D class so that the following console window can be shown. package April27; public class Point { private int x, y; public Point(int x, int y) { this.x=x; this.y=y; } public int getX() {return x;} public int getY() {return y;} protected void move(int x, int y) { this.x=x; this.y=y; } } package April27;..

1. Develop a simple program of reservation system for a concert. The specification of the system is as follows. • There are three seat types: S type, A type, B type. • The number of seats for each row is fixed to be 16. • There are four menu for reservation system: Reserve, Search, Cancel, Quit • For Reserve menu, only one seat can be reserved for each reservation. The program should receive the..