Bonjour, je ne comprends pas le résultat de ce programme :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Good{
	private int a; protected int c;
	Good(int a){ this.a = a; c= 0; a=0;}
	String s(){ return a + "." + c;}
 
}
 
class Great extends Good{
	protected int c;
	Great(int a){ super(a); c= 1;}
 
}
 
class Greater extends Great{
	int a;
	Greater(int a){ super(a); this.a= 2;}
	String s(){ return a + "." + c;}
 
}
public class test {
 
	public static void main(String args[]) {
		Good g = new Good(1); System.out.println(g.s());
		Great g2 = new Great(2); System.out.println(g2.s());
		Greater g3 = new Greater(3); System.out.println(g3.s());
	}
}
Il m'affichage les valeurs suivantes :

Pourquoi dans le deuxième print c = 0 et pas 1 ?