SlideShare a Scribd company logo
1 of 103
Download to read offline
PL
 in
 Java
 
 
Week03
 
I n h e r i t a n c e
조영호
 
snatcher@nhn.com
 
상속
Conceptual Perspective
 
Implementation Perspective
 
객체지향
 
Object-Orientation
 
개념
 관점
 
구현
 관점
 
Conceptual Perspective
 
Implementation Perspective
 
객체지향
 
Object-Orientation
 
개념
 관점
 
구현
 관점
 
Type
 
Class
 
Conceptual Perspective
 
Implementation Perspective
 
객체지향
 
Object-Orientation
 
개념
 관점
 
구현
 관점
 
Generalization
 
Inheritance
 
To p i c s
 
Inheritance
Generalization
Composition
Method Overriding
super
super()
사람
 
요츠바
 
5살
 
class Person {	
String name;	
int age;	
	
Person() {	
this(사람, 1);	
}	
Person(String name, int age) {	
this.name = name;	
this.age= age;	
}	
String introduce() {	
return 이름 :  + name + , 나이  + age + 세;	
}	
}	
Person
 
Person yotsuba = new Person(요츠바, 5);	
System.out.println(yotsuba.introduce());
Person yotsuba = new Person(요츠바, 5);	
name = 요츠바
age = 5
 
Person
new Person()
 
킬러
 
class Killer {	
String name;	
int age;	
String warning;	
String weapon;	
Killer(String name, int age, String warning, 	
String weapon) {	
this.name = name;	
this.age = age;	
this.warning = warning;	
this.weapon = weapon ;	
}	
	
String introduce() {	
return 이름 :  + name + , 나이  + age + 세;	
}	
String getWeapon() {	
return weapon;	
}	
}	
Killer
 
Killer killerYotsuba = new Killer(요츠바, 5, You can tell me in hell., 총);	
System.out.println(killerYotsuba.introduce());	
System.out.println(killerYotsuba.getWeapon());
Killer killerYotsuba = new Killer(요츠바, 5, 	
You can tell me in hell., 총);	
name = 요츠바
age = 5
warning = You..
weapon = 총
 
Killer
new Killer()
 
Person  Killer
 
Person
 
name
age
 
introduce()
 
Killer
 
name
age
warning
weapon
 
introduce()
getWeapon()
 
Code Duplication
 
Person
 
name
age
 
introduce()
 
Killer
 
name
age
warning
weapon
 
introduce()
getWeapon()
 
Inheritance
 
Person
 
name
age
 
introduce()
 
Killer
 
warning
weapon
 
getWeapon()
 
class Killer extends Person {	
String warning;	
String weapon;	
Killer(String name, int age, String warning, String weapon) {	
this.name = name;	
this.age = age;	
this.warning = warning;	
this.weapon = weapon;	
}	
String getWeapon() {	
return weapon;	
}
}	
Killer extends Person
 
Person yotsuba = new Person(요츠바, 5);	
name = 요츠바
age = 5
 
Person
Killer killerYotsuba = new Killer(요츠바, 5, 	
You can tell me in hell., 총);	
name = 요츠바
age = 5
warning = You..
weapon = 총
 
Killer
Member Variable Inheritance
 
Person yotsuba = new Person(요츠바, 5);	
	
System.out.println(yotsuba.introduce());	
	
	
	
Killer killerYotsuba = new Killer(요츠바, 5, 	
You can tell me in hell., 총);	


System.out.println(killerYotsuba.introduce());	
System.out.println(killerYotsuba.getWeapon());	
Method Inheritacne
 
음악가
 
Person
Code Reuse
 
Inheritance
 
Person
 
name
age
 
introduce()
 
Musican
 
instrument
play()
 
public class Musician extends Person {	
String instrument;	
Musician(String name, int age, String instrument) {	
this.name = name;	
this.age = age;	
this.instrument = instrument;	
}	
String play() {	
return instrument +  연주;	
}	
}	
Musician extends Person
 
Musician musicanYotsuba = new Musician(요츠바, 5, 피리);	
System.out.println(musicanYotsuba.introduce());	
System.out.println(musicanYotsuba.play());
Code Reuse

More Related Content

Viewers also liked

[JWAP-2] DI & Spring
[JWAP-2] DI & Spring[JWAP-2] DI & Spring
[JWAP-2] DI & Spring
Young-Ho Cho
 
객체지향적인 도메인 레이어 구축하기
객체지향적인 도메인 레이어 구축하기객체지향적인 도메인 레이어 구축하기
객체지향적인 도메인 레이어 구축하기
Young-Ho Cho
 
[PreSchool-1] 프로그래밍 '개념' 맛보기
[PreSchool-1] 프로그래밍 '개념' 맛보기[PreSchool-1] 프로그래밍 '개념' 맛보기
[PreSchool-1] 프로그래밍 '개념' 맛보기
Young-Ho Cho
 
Roles, Responsibilities, Collaborations
Roles, Responsibilities, CollaborationsRoles, Responsibilities, Collaborations
Roles, Responsibilities, Collaborations
Young-Ho Cho
 
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
TelecomJournal
 

Viewers also liked (19)

[NEXT 프연 Week2] UNIX 명령어 간단하게 살펴보기
[NEXT 프연 Week2] UNIX 명령어 간단하게 살펴보기[NEXT 프연 Week2] UNIX 명령어 간단하게 살펴보기
[NEXT 프연 Week2] UNIX 명령어 간단하게 살펴보기
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
[JWAP-2] DI & Spring
[JWAP-2] DI & Spring[JWAP-2] DI & Spring
[JWAP-2] DI & Spring
 
객체지향적인 도메인 레이어 구축하기
객체지향적인 도메인 레이어 구축하기객체지향적인 도메인 레이어 구축하기
객체지향적인 도메인 레이어 구축하기
 
[JWPA-1]의존성 주입(Dependency injection)
[JWPA-1]의존성 주입(Dependency injection)[JWPA-1]의존성 주입(Dependency injection)
[JWPA-1]의존성 주입(Dependency injection)
 
[PreSchool-1] 프로그래밍 '개념' 맛보기
[PreSchool-1] 프로그래밍 '개념' 맛보기[PreSchool-1] 프로그래밍 '개념' 맛보기
[PreSchool-1] 프로그래밍 '개념' 맛보기
 
도메인구현 KSUG 20151128
도메인구현 KSUG 20151128도메인구현 KSUG 20151128
도메인구현 KSUG 20151128
 
[NHN NEXT] 2014 NHN NEXT 창의체험
[NHN NEXT] 2014 NHN NEXT 창의체험[NHN NEXT] 2014 NHN NEXT 창의체험
[NHN NEXT] 2014 NHN NEXT 창의체험
 
Domain Driven Design Ch7
Domain Driven Design Ch7Domain Driven Design Ch7
Domain Driven Design Ch7
 
DDD 산책
DDD 산책DDD 산책
DDD 산책
 
Roles, Responsibilities, Collaborations
Roles, Responsibilities, CollaborationsRoles, Responsibilities, Collaborations
Roles, Responsibilities, Collaborations
 
DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)DDD 구현기초 (거의 Final 버전)
DDD 구현기초 (거의 Final 버전)
 
OHS Certificate
OHS CertificateOHS Certificate
OHS Certificate
 
Steviose
StevioseSteviose
Steviose
 
Презентация 1.13 - Солнечно-водородное электроснабжение жилого комплекса в Та...
Презентация 1.13 - Солнечно-водородное электроснабжение жилого комплекса в Та...Презентация 1.13 - Солнечно-водородное электроснабжение жилого комплекса в Та...
Презентация 1.13 - Солнечно-водородное электроснабжение жилого комплекса в Та...
 
Química dos Elementos de Transição Experimental - Experimento I - Heranitrito...
Química dos Elementos de Transição Experimental - Experimento I - Heranitrito...Química dos Elementos de Transição Experimental - Experimento I - Heranitrito...
Química dos Elementos de Transição Experimental - Experimento I - Heranitrito...
 
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
MICT presentation on Thailand’s Important Mission for Spectrum Re-farming
 
dave
davedave
dave
 
SIO_110_syllabus
SIO_110_syllabusSIO_110_syllabus
SIO_110_syllabus
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

[NHN NEXT] Java 강의- Week3