SlideShare une entreprise Scribd logo
1  sur  4
sobrecarga
super clase
==================================================
class TGr{
private int x;
public int getx(){
return x;
}
publi void setx(int _x){
X=_x;
}
public TGr(int _x)
{
x=_X;
}
publi TGr()
{
x=10;
}
}
=============================================
class TGr1 extends TGr{
private int area;
public TGr1()
{
super(10);
//super();
}
public TGr1(int _x)
{
super(50);
setx(100)
}
}
==============================================
MAIN
TGr1 obj1=new TGr1(30)
printf(obj1.getx());
=====================
imprime
100;
================================================================================
=============================================
sobreescritura
ejemplo1
super clase
==================================================
class TGr{
private int x;
public int getx(){
return x;
}
publi void setx(int _x){
X=_x;
}
public TGr(int _x)
{
x=_X;
}
publi TGr()
{
x=10;
}
}
=============================================
class TGr1 extends TGr{
private int area;
public int get(): es igualito al de get de TGr:
{
//return 80;
retur super.getx();
}
public TGr1()
{
super(10);
//super();
}
public TGr1(int _x)
{
super(_x);
}
publi Dibujar()
{
printf(getx());este metodo llama al metodo redifinido
}
}
==============================================
MAIN
TGr1 obj1=new TGr1(30)
printf(obj1.getx());
=====================
imprime
30;
==================================================================
ejemplo 2
super clase
==================================================
class TGr{
private int x;
public int getx(){
return x;
}
publi void setx(int _x){
X=_x;
}
public TGr(int _x)
{
x=_X;
}
publi TGr()
{
x=10;
}
}
=============================================
class TGr1 extends TGr{
private int area;
public int get(): es igualito al de get de TGr:
{
//return 80;
retur super.getx();
}
public TGr1()
{
super(10);
//super();
}
public TGr1(int _x)
{
super(_x);
}
publi Dibujar()
{
printf(getx());este metodo llama al metodo redifinido
printf(super.getx())
}
}
==============================================
MAIN
TGr obj1=new TGr (30): del papa
TGr1 obj1=new TGr1 (30): del hijo
TGr obj1=new TGr1 (30)¨: se hace esto por herencia: la diferencia e por
polimorfidmo alas dos anteriores :
TGr1 obj1=new TGr (30)¨: error de compilacion
printf(obj1.getx());
obj1.Dibujar()
=====================
imprime
30;

Contenu connexe

Tendances

UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10megaplanet20
 
Dérivation et Intégration numériques
Dérivation et Intégration numériquesDérivation et Intégration numériques
Dérivation et Intégration numériquesJaouad Dabounou
 
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Yessin Abdelhedi
 
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTITD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTIsoufiane merabti
 
Traitement des images avec matlab
Traitement des images avec matlabTraitement des images avec matlab
Traitement des images avec matlabomar bllaouhamou
 
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdf
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdfFonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdf
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdfetude-generale
 
Fonctions exponentielles et puissances
Fonctions exponentielles et puissancesFonctions exponentielles et puissances
Fonctions exponentielles et puissancesĂmîʼndǿ TrànCè
 
Exercice fonctions réciproques
Exercice fonctions réciproquesExercice fonctions réciproques
Exercice fonctions réciproquesYessin Abdelhedi
 
1re s probabilite_variable_aleatoire
1re s probabilite_variable_aleatoire1re s probabilite_variable_aleatoire
1re s probabilite_variable_aleatoireJawhar Farhat
 
Rappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comRappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comcours fsjes
 

Tendances (20)

Ch04 25
Ch04 25Ch04 25
Ch04 25
 
Chapitre2 2
Chapitre2 2Chapitre2 2
Chapitre2 2
 
01 lois-à-densité
01 lois-à-densité01 lois-à-densité
01 lois-à-densité
 
UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10UML OCL : Cheat Sheet - 10
UML OCL : Cheat Sheet - 10
 
3-Cm8 2013-2014
3-Cm8 2013-20143-Cm8 2013-2014
3-Cm8 2013-2014
 
Dérivation et Intégration numériques
Dérivation et Intégration numériquesDérivation et Intégration numériques
Dérivation et Intégration numériques
 
Ch16 20
Ch16 20Ch16 20
Ch16 20
 
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
Devoir de synthèse_n°_02--2008-2009(mr_otay)[lycée__el_aghaliba]
 
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTITD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
TD - travaux dirigé limite de fonction ( exercice ) SOUFIANE MERABTI
 
Traitement des images avec matlab
Traitement des images avec matlabTraitement des images avec matlab
Traitement des images avec matlab
 
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdf
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdfFonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdf
Fonction-exponentielle-2eme-BAC-PC --www.etude-generale.com.pdf
 
05 exos fonction_exponentielle
05 exos fonction_exponentielle05 exos fonction_exponentielle
05 exos fonction_exponentielle
 
246242769 sequence-1-pdf
246242769 sequence-1-pdf246242769 sequence-1-pdf
246242769 sequence-1-pdf
 
Fonctions exponentielles et puissances
Fonctions exponentielles et puissancesFonctions exponentielles et puissances
Fonctions exponentielles et puissances
 
Exercice fonctions réciproques
Exercice fonctions réciproquesExercice fonctions réciproques
Exercice fonctions réciproques
 
1re s probabilite_variable_aleatoire
1re s probabilite_variable_aleatoire1re s probabilite_variable_aleatoire
1re s probabilite_variable_aleatoire
 
Rappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.comRappels math - www.coursdefsjes.com
Rappels math - www.coursdefsjes.com
 
Trigo powerpoint
Trigo powerpointTrigo powerpoint
Trigo powerpoint
 
Programmation linéaire
Programmation linéaireProgrammation linéaire
Programmation linéaire
 
Ch14 18
Ch14 18Ch14 18
Ch14 18
 

En vedette

Construcción de una escuela democrática
Construcción de una escuela democráticaConstrucción de una escuela democrática
Construcción de una escuela democráticaconsuelo553
 
Язык ДРАКОН: вводный курс, часть 3
Язык ДРАКОН: вводный курс, часть 3Язык ДРАКОН: вводный курс, часть 3
Язык ДРАКОН: вводный курс, часть 3Stepan Mitkin
 
Язык ДРАКОН: вводный курс, часть 2
Язык ДРАКОН: вводный курс, часть 2Язык ДРАКОН: вводный курс, часть 2
Язык ДРАКОН: вводный курс, часть 2Stepan Mitkin
 
DRAKON Visual Language: Tutorial. Part 2
DRAKON Visual Language: Tutorial. Part 2DRAKON Visual Language: Tutorial. Part 2
DRAKON Visual Language: Tutorial. Part 2Stepan Mitkin
 
DRAKON Visual Language: Tutorial. Part 3
DRAKON Visual Language: Tutorial. Part 3DRAKON Visual Language: Tutorial. Part 3
DRAKON Visual Language: Tutorial. Part 3Stepan Mitkin
 
DRAKON Visual Language: Tutorial. Part 1
DRAKON Visual Language: Tutorial. Part 1DRAKON Visual Language: Tutorial. Part 1
DRAKON Visual Language: Tutorial. Part 1Stepan Mitkin
 
Язык ДРАКОН: вводный курс, часть 1
Язык ДРАКОН: вводный курс, часть 1Язык ДРАКОН: вводный курс, часть 1
Язык ДРАКОН: вводный курс, часть 1Stepan Mitkin
 
Construcción de una escuela democrática
Construcción de una escuela democráticaConstrucción de una escuela democrática
Construcción de una escuela democráticaconsuelo553
 

En vedette (11)

Construcción de una escuela democrática
Construcción de una escuela democráticaConstrucción de una escuela democrática
Construcción de una escuela democrática
 
Personal b maricela
Personal b maricelaPersonal b maricela
Personal b maricela
 
Язык ДРАКОН: вводный курс, часть 3
Язык ДРАКОН: вводный курс, часть 3Язык ДРАКОН: вводный курс, часть 3
Язык ДРАКОН: вводный курс, часть 3
 
Язык ДРАКОН: вводный курс, часть 2
Язык ДРАКОН: вводный курс, часть 2Язык ДРАКОН: вводный курс, часть 2
Язык ДРАКОН: вводный курс, часть 2
 
DRAKON Visual Language: Tutorial. Part 2
DRAKON Visual Language: Tutorial. Part 2DRAKON Visual Language: Tutorial. Part 2
DRAKON Visual Language: Tutorial. Part 2
 
DRAKON Visual Language: Tutorial. Part 3
DRAKON Visual Language: Tutorial. Part 3DRAKON Visual Language: Tutorial. Part 3
DRAKON Visual Language: Tutorial. Part 3
 
DRAKON Visual Language: Tutorial. Part 1
DRAKON Visual Language: Tutorial. Part 1DRAKON Visual Language: Tutorial. Part 1
DRAKON Visual Language: Tutorial. Part 1
 
Язык ДРАКОН: вводный курс, часть 1
Язык ДРАКОН: вводный курс, часть 1Язык ДРАКОН: вводный курс, часть 1
Язык ДРАКОН: вводный курс, часть 1
 
Informacion bgu-web
Informacion bgu-webInformacion bgu-web
Informacion bgu-web
 
Agile tester 3.0
Agile tester 3.0Agile tester 3.0
Agile tester 3.0
 
Construcción de una escuela democrática
Construcción de una escuela democráticaConstrucción de una escuela democrática
Construcción de una escuela democrática
 

Herencia

  • 1. sobrecarga super clase ================================================== class TGr{ private int x; public int getx(){ return x; } publi void setx(int _x){ X=_x; } public TGr(int _x) { x=_X; } publi TGr() { x=10; } } ============================================= class TGr1 extends TGr{ private int area; public TGr1() { super(10); //super(); } public TGr1(int _x) { super(50); setx(100) } } ============================================== MAIN TGr1 obj1=new TGr1(30) printf(obj1.getx()); ===================== imprime
  • 2. 100; ================================================================================ ============================================= sobreescritura ejemplo1 super clase ================================================== class TGr{ private int x; public int getx(){ return x; } publi void setx(int _x){ X=_x; } public TGr(int _x) { x=_X; } publi TGr() { x=10; } } ============================================= class TGr1 extends TGr{ private int area; public int get(): es igualito al de get de TGr: { //return 80; retur super.getx(); } public TGr1() { super(10); //super(); } public TGr1(int _x) { super(_x); }
  • 3. publi Dibujar() { printf(getx());este metodo llama al metodo redifinido } } ============================================== MAIN TGr1 obj1=new TGr1(30) printf(obj1.getx()); ===================== imprime 30; ================================================================== ejemplo 2 super clase ================================================== class TGr{ private int x; public int getx(){ return x; } publi void setx(int _x){ X=_x; } public TGr(int _x) { x=_X; } publi TGr() { x=10; } } ============================================= class TGr1 extends TGr{ private int area; public int get(): es igualito al de get de TGr: { //return 80; retur super.getx();
  • 4. } public TGr1() { super(10); //super(); } public TGr1(int _x) { super(_x); } publi Dibujar() { printf(getx());este metodo llama al metodo redifinido printf(super.getx()) } } ============================================== MAIN TGr obj1=new TGr (30): del papa TGr1 obj1=new TGr1 (30): del hijo TGr obj1=new TGr1 (30)¨: se hace esto por herencia: la diferencia e por polimorfidmo alas dos anteriores : TGr1 obj1=new TGr (30)¨: error de compilacion printf(obj1.getx()); obj1.Dibujar() ===================== imprime 30;