일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 스프링
- http 메시지 컨버터
- 의존관계
- objecterror
- 추상클래스
- 스프링컨테이너
- 백준
- 티스토리챌린지
- 서블릿
- 오블완
- html form
- 인터페이스
- JSON
- java
- 코드트리
- 싱글톤
- 다형성
- 예외와 트랜잭션 커밋
- @configuration
- 코드트리조별과제
- 참조변수
- 프록시
- 테스트코드
- HttpServletResponse
- DI
- equals()
- 김영한
- 오버라이딩
- 코딩테스트
- fielderror
- Today
- Total
목록java (4)
minOS

ch7-23 다형성 - 여러가지 형태를 가질 수 있는 능력 - 조상타입 참조변수로 자손 타입 객체를 다루는 것 - 자손 타입의 참조변수로 조상 타입의 객체를 가리킬 수 없다 class Tv{ boolean power; int channel; void power(){power =! power;} void channelUp(){++channel;} void channelDown(){--channel;} } class SmartTv extends Tv{ String text; //자막 void caption(){} } public class Main { public static void main(String[] args) { SmartTv s1 = new SmartTv(); // 1) 참조변수와 인스턴스의 타..

ch7-7 오버라이딩 - 상속 받은 조상의 메서드를 자신에게 맞게 변경하는 것 예시1 class Point { int x; int y; String getLocation(){ return "x:" + x + " y:"+y; } } class Point3D extends Point{ int z; //조상의 getLocation()을 오버라이딩 String getLocation(){ return "x:" + x + " y:"+y +" z:"+z; } } public class Main { public static void main(String[] args) { Point3D p = new Point3D(); p.x=3; p.y=8; p.z=5; System.out.println(p.getLocation())..

ch7-5 단일상속 - 자바는 단일 상속만 하용( c++ 은 다중상속 가능) 다중 상속시 부모 클래스에 메소드 이름이 같고, 기능이 다르면 충돌이 일어나기 때문에 OPP 설계로 부적절함 - 다중 상속의 기능을 하도록 만드는 법 1)비중이 높은 클래스 하나만 상속관계로 정의하고 나머지는 포함관계로 만든다. class Tv{ boolean power; int channel =10; void power(){power=!power;} //전원상태 변경 void channelUp(){++channel;} //채널 +1 void channelDown(){--channel;} //채널 -1 } class Dvd { // 멤버 변수 boolean power; int channel=20; // 전원 상태 변경 메서드 v..

상속(inheritance) - 기존의 클래스로 새로운 클래스를 작성하는 것 (코드의 재사용) -두 클래스를 부모와 자식으로 관계를 맺어 주는 것 형태 class 자식클레스 extends 부모클래스 { } 예시 class Parent {} class Child extends Parent { //.. } - 자손은 조상의 모든 멤버를 상속 받는다 (생성자,초기화 블럭 제외) -자손의 멤버 개수는 조상보다 적을 수 없다. class Parent{ int age; } class Child extends Parent{ void play(){ System.out.println("놀자"); } } public class Main { public static void main(String[] args) { Child..