Documentos de Académico
Documentos de Profesional
Documentos de Cultura
1)
a. Le programme affiche
Test: POO, Java 8 2
Test: POO, 8 2
8
3
b. Le programme affiche
Test: POO, Java 8 1
Test: POO, 8 2
8
3
2)
a. Le programme affiche
POO SMI
POO SMI
POO SMI
Info5 SMA
Info5 SMA
Info5 SMA
4 -1 2
b. Le programme n'est pas compil parce que un programme Java est constitu dune
ou de plusieurs classes. Mais ne peut contenir quune seule classe publique
contenant la mthode main().
Exercice 2 [ 9 pts]
class Personn {
private String nom;
private int age;
public Personn(String nom, int age)
{
this.nom=nom;
this.age = age;
}
1/3
public Personn(){
this("Elhadi", 20);
}
public Personn(Personn p) {
nom = p.nom;
age = p.age;
}
2/3
public void afficher() {
System.out.println("Je suis un Etudiant(e)\n");
super.afficher();
System.out.println("Ma filire est:"+ fil);
}
}
////////////////////////////////////////////////////
public class TestPersEtud{
public static void main(String[] args) {
Personn p1 = new Personn("Elhadi ",20);
p1.afficher();
Personn p2 = new Personn();
p2.afficher();
Personn p3 = new Personn(p2);
p3.afficher(true);
boolean bool1=p1.egalite(p2);
System.out.println("Mme Personne:"+bool1);
///////////////////////////
Etudian e1 = new Etudian(p1,"SMI5");
e1.afficher();
Etudian e2 = new Etudian("hachimi", 20,"SMI5");
e2.afficher();
boolean bool2=Etudian.egalite(e1,e2);
System.out.println("Mme Etudiant:"+bool2);
}
}
3/3