Java-9강

2009년 1월 5일 9강

9장 Polymorphism

객체지향의 완성은 “다형성”

  • Is a powerful feature of OO
  • Means “many forms”
  • Is the ability to have many different forms
Can be used in two ways:
  • polymorphic parameters
  • heterogeneous collections
instanceof
부모, 자식 형변환 가능한지 여부를 확인 true, false 를 리턴.
오리지날 타입을 알기 위해 사용.
- 다형성의 문제
자식은 부모형으로 형변환 될 수 있다라는 점이 문제.
그래서 나온 것이 Generic (15장에서 배움)

Overriding Methods

Virtual method invocation:
Employee e = new Manager();
e.getDetails();
Complie-time type and runtime type
선언형이나 실제형이냐..
- Rules about Overriden Methods
cannot be less accessible than the method it overrides.

10장

Abstract Method

자식클래스에서 무조건 재정의 해야함.
오버라이드의 강제화를 위해..

Abstract Class

추상 메서드를 갖고 있다면 무조건 추상 클래스로 된다.
정상적인 클래스도 abstract를 쓸 수 있다. 이유는 new를 통한 인스턴스생성을 못하게 하려고..
  • member variable
  • static variable
  • member method
  • static method
  • abstract method
위에 5가지로 추상 클래스를 만들 수 있다.

Interface
  • an interface is variation on the idea of an abstract class.
  • In an interface, all the methods are abstract.
  • In an interface, all variables are constant.
추상클래스 계열
클래스는 아님.
부모가 여러 개여도 됨(다중상속)
  • abstract method
  • constant
인터페이스는 위의 2개로 구성
인터페이스 속에는 모두 static, final이므로 생략가능한다.
자식 부모
class extends class
interface extends interface
class implements interface
interface
  • 다중상속
  • Mark(flag) interface – 멤버가 하나도 없는 인터페이스, UML은 동그라미표시
내일은
mark interface
객체의 주소, 값 복제
내부클래스
빨리끝나면 GUI
그래픽 인터페이스 이벤트 모델

Java + .NET -> actionScript
JDBC -> .NET의 ADO.NET
JSP -> ASP.NET
Comment are closed.