코락 CoRock
코딩하는 락스타
코락 CoRock
  • 분류 전체보기 (393)
    • frameworks (19)
      • spring (19)
      • spring-boot (0)
      • testing (0)
    • languages (94)
      • java (39)
      • kotlin (0)
      • python (42)
      • r (13)
    • libraries (0)
    • programming (239)
      • android (13)
      • c (17)
      • cpp (22)
      • database (18)
      • design-pattern (4)
      • data-structures (11)
      • git (8)
      • hadoop (6)
      • html-css (7)
      • issue (4)
      • javascript (26)
      • jsp (34)
      • os (29)
      • php (6)
      • preferences (19)
      • etc (15)
    • discography (37)
      • k-pop (18)
      • pop (19)
    • blog (3)

블로그 메뉴

  • Programming
  • Java
  • JavaScript
  • Discography
  • K-Pop Songs
  • Pop Songs
  • Blog
  • Guestbook

공지사항

인기 글

태그

  • jsp
  • javascript
  • Java
  • Spring
  • 파이썬
  • python
  • Android
  • 자바스크립트
  • CentOS
  • r
  • linux
  • oracle

최근 댓글

최근 글

티스토리

반응형
hELLO · Designed By 정상우.
코락 CoRock

코딩하는 락스타

programming/c

Inheritance

2018. 2. 7. 14:23
반응형


Inheritance


연관된 일련의 class들에 대해 공통적인 규약을 정의할 수 있다.



ㆍ 상속의 대상이 되는 클래스

- 상위 클래스(super class) / 기초 클래스(base class) / 부모 클래스(parent class)

- 하위 클래스 / 유도 클래스 / 자식 클래스




자바는 프로그램이 복잡해지는 것을 막기 위해 다중 상속이 아닌 단일 상속만을 지원한다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AA {
    
    public void display() {
        System.out.println("I'm AA!");
    }
    
}
 
public class InherTest01 extends AA {
    
    public static void main(String[] args) {
        
        InherTest01 in = new InherTest01();
 
        System.out.println(in.toString());
        // == System.out.println(in);
 
        in.display();    // inherited class AA
        
    }
 
}
Colored by Color Scripter
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class BB {
    
    public void display() {
        System.out.println("I'm BB!");
    }
    
}
 
public class InherTest02 extends BB {
 
    public String toString() {
        return "Superman!";
    }
 
    public static void main(String[] args) {
        
        InherTest02 in = new InherTest02();
 
        System.out.println(in);
 
    }
    
}
Colored by Color Scripter
cs
반응형
저작자표시 비영리 변경금지 (새창열림)
    'programming/c' 카테고리의 다른 글
    • [Core C] Array | 배열
    • String Class
    • 주말숙제
    • [Algorithm] Baby Gin
    코락 CoRock
    코락 CoRock
    A COder dreaming of being a ROCKstar

    티스토리툴바