Design Issues

Similar documents
PowerPoint Presentation

gnu-lee-oop-kor-lec06-3-chap7

PowerPoint Presentation

PowerPoint Presentation

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

JAVA PROGRAMMING 실습 08.다형성

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

PowerPoint Presentation

PowerPoint Presentation

PowerPoint 프레젠테이션

5장.key

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

PowerPoint Presentation

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

PowerPoint 프레젠테이션

비긴쿡-자바 00앞부속

PowerPoint Presentation

JAVA PROGRAMMING 실습 09. 예외처리

PowerPoint 프레젠테이션

쉽게 풀어쓴 C 프로그래밍

PowerPoint 프레젠테이션

02 C h a p t e r Java

JAVA PROGRAMMING 실습 07. 상속

자바 프로그래밍

PowerPoint Presentation

PowerPoint 프레젠테이션

Microsoft PowerPoint - Java7.pptx

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

PowerPoint 프레젠테이션

제11장 프로세스와 쓰레드

PowerPoint Presentation

chap10.PDF

PowerPoint Presentation

JAVA PROGRAMMING 실습 05. 객체의 활용

Cluster management software

Microsoft Word - java19-1-midterm-answer.doc

Microsoft Word - EEL2 Lab4.docx

05-class.key

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

PowerPoint Presentation

PowerPoint 프레젠테이션

슬라이드 1

No Slide Title

Microsoft PowerPoint - 2강

Network Programming

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345])

PowerPoint 프레젠테이션

슬라이드 1

쉽게 풀어쓴 C 프로그래밍

Microsoft PowerPoint - 04-UDP Programming.ppt

JAVA PROGRAMMING 실습 05. 객체의 활용

Microsoft PowerPoint - Lect04.pptx

PowerPoint Presentation

교육자료

JAVA PROGRAMMING 실습 02. 표준 입출력

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

<4D F736F F F696E74202D20C1A63234C0E520C0D4C3E2B7C228B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

예외 예외정의예외발생예외처리예외전파 단정 단정의선언 단정조건검사옵션 2

쉽게 풀어쓴 C 프로그래밍

1

ThisJava ..

A Tour of Java V

TEST BANK & SOLUTION

9장.예외와 단정

PowerPoint Presentation

JAVA PROGRAMMING 실습 02. 표준 입출력

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

Java ...

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

초보자를 위한 자바 2 21일 완성 - 최신개정판

Semantic Consistency in Information Exchange

PowerPoint Template

PowerPoint 프레젠테이션

Microsoft PowerPoint - additional08.ppt [호환 모드]

01-OOPConcepts(2).PDF

Microsoft PowerPoint - 03-TCP Programming.ppt

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074>

JUNIT 실습및발표

Microsoft PowerPoint 장강의노트.ppt

슬라이드 1

PowerPoint Presentation

untitled

PowerPoint Presentation

쉽게

C++ Programming

PowerPoint 프레젠테이션

KAA2005.9/10 Ãâ·Â

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

PowerPoint 프레젠테이션

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

Since 2009

Microsoft Word - java19-1-final-answer.doc

슬라이드 1

Microsoft PowerPoint - Chapter 6.ppt

07 자바의 다양한 클래스.key


Java

Microsoft PowerPoint - lec12 [호환 모드]

PowerPoint Presentation

Transcription:

11 COMPUTER PROGRAMMING INHERIATANCE

CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2

Overview of Inheritance Declaration format of Class including Inheritance [public/final/abstract] class ClassName extends SupperClassName {... // Declaration of member variable... // Constructor... // Declaration of method 3

Inheritance of Member Variable Example of Member Variable Inheritance class A { int aa = 1; class B extends A { int bb = 2; class C extends B { int cc = 3; class Dabc { public static void main(string[] args) { C objc = new C(); System.out.println("objc 객체의객체속성변수 aa 의값은 " + objc.aa); System.out.println("objc 객체의객체속성변수 bb 의값은 " + objc.bb); System.out.println("objc 객체의객체속성변수 cc 의값은 " + objc.cc); 4

Inheritance of Member Variable class C1 { static int x; static int y; class C2 extends C1 { static String x; class Inheritance3 { C2.x = " 알기쉽게해설한자바 "; C2.y = 20000; C1.x = 30000; System.out.println(" 클래스변수 C2.x 값 : " + C2.x); System.out.println(" 클래스변수 C2.y 값 (C1 으로부터상속 ) : " + C2.y); System.out.println(" 클래스변수 C1.x 값 : " + C1.x); 5

Reserved Word - super class D1 { int x = 1000; void display() { System.out.println(" 상위클래스 D1 의 display() 메소드입니다 "); class D2 extends D1 { int x = 2000; void display() { System.out.println(" 하위클래스 D2 의 display() 메소드입니다 "); void write() { this.display(); super.display(); System.out.println("D2 클래스객체의 x 값은 : " + x); System.out.println("D1 클래스객체의 x 값은 : " + super.x); class InheritanceSuper { D2 d = new D2(); d.write(); 6

Method Inheritance and Overriding class A { int i; int j; void setij(int x, int y) { i = x; j = y; class B extends A { int total; void sum() { total = i + j; class Inheritance4 { B subob = new B(); subob.setij(10, 12); subob.sum(); System.out.println(" 두수의합계는 : " + subob.total); 7

Method Inheritance and Overriding class A { void show(string str) { System.out.println(" 상위클래스의메소드 show(string str) 수행 " + str); class B extends A { void show() { System.out.println(" 하위클래스의메소드 show() 수행 "); class OverrideExam1 { B over = new B(); over.show(" 알기쉽게해설한자바 "); over.show(); 8

Method Inheritance and Overriding class A { void show() { System.out.println(" 상위클래스의메소드 show(string str) 수행 "); class B extends A { void show() { System.out.println(" 하위클래스의메소드 show() 수행 "); class OverrideExam2 { B over = new B(); over.show(); 9

Method Inheritance and Overriding class A { int i, j; A(int a, int b) { i = a; j = b; void show() { System.out.println(" 상위클래스의메소드 show() 수행 "); class B extends A { int k; B(int a, int b, int c ) { super(a,b); k = c; void show() { System.out.println(" 하위클래스의메소드 show() 수행 "); System.out.println("===super 를이용한상위클래스메소드호출 ==="); super.show(); class OverrideExam3 { B over1 = new B(10, 20, 30); System.out.println("i, j, k 의값 : " + over1.i + " " + over1.j + " " + over1.k); over1.show(); 10

Inheritance and Constructor class A1 { double d1; A1() { System.out.println(" 클래스 A1 의생성자수행 "); d1 = 10*10; class A2 extends A1 { double d2; A2() { System.out.println(" 클래스 A2 의생성자수행 "); d2 = 10*10*10; class A3 extends A2 { double d3; A3() { System.out.println(" 클래스 A3 의생성자수행 "); d3 = 10*10*10*10; class Constructors1 { A3 super1 = new A3(); System.out.println("10 의 2 제곱 : " + super1.d1); System.out.println("10 의 3 제곱 : " + super1.d2); System.out.println("10 의 4 제곱 : " + super1.d3); 11

Inheritance and Overriding class A1 { int d1; int s; A1(int s1) { System.out.println(" 클래스 A1 의생성자수행 "); s = s1; d1 = s * s ; class A2 extends A1 { int d2; int t; A2(int s1, int t1) { super(s1); System.out.println(" 클래스 A2 의생성자수행 "); t = t1; d2 = t * t ; class Constructors2 { A2 super2 = new A2(10,20); System.out.println("10 의제곱은 : " + super2.d1); System.out.println("20 의제곱은 : " + super2.d2); 12

Type Conversion of Object Object type conversion in classes of inheritance relation class Acast { int a=1; class Bcast extends Acast { int b=2; class Ccast extends Bcast { int c=3; class TestCasting { public static void main(string[] args) { Acast refa; refa = new Ccast(); Acast 타입의객체 refa 선언 System.out.println("refA.a 의값은 "+refa.a); 13

CONCLUDE OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 14